peter-evans / create-or-update-comment

A GitHub action to create or update an issue or pull request comment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GITHUB_TOKEN permissions that needs write access

samirergaibi opened this issue · comments

Since it's now possible to control the permissions of the GITHUB_TOKEN on a job basis (https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/) it would be nice to know what permissions need write access to get this job to work.

I've currently set all of my repos permissions to read and then the job failed using this action with the following error
image

After reading the readme I found that this is expected and is caused by not having the correct permissions.
So it would be really awesome if it could be added to the readme what permissions are required to have write access for this action to work.

Hi @samirergaibi

I've not tested it yet, but I think you only need issues: write.

permissions:
  issues: write

Once confirmed, I'll add it to the readme.

Thank you for the fast response @peter-evans !

Looks like it needs write permission for more than just issues, after changing it the job is set up with these permissions
image

But still get the same error
image

EDIT:
Don't know if it might be of any help but the step looks like this:
image

What worked for me in the end was setting the pull-requests scope to write permission.

permissions:
  pull-requests: write

Good to know. Thank you.

I guess it depends on your use case. i.e. Whether you are creating comments on a pull request or an issue.

I've updated the readme with details of the scopes required. Thank you for raising this and investigating!

commented

Sorry to interrupt, but can someone here tell me exactly how to adjust the permissions?

I've tried adding permissions in the workflow file and changing repository settings, but nothing worked.

Permission

I am really out of ideas, what should I do? I really need help! Any advice would be appreciated! Thanks!