Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource not accessible by integration #3236

Closed
wiiznokes opened this issue Aug 22, 2024 · 6 comments
Closed

Resource not accessible by integration #3236

wiiznokes opened this issue Aug 22, 2024 · 6 comments

Comments

@wiiznokes
Copy link

Maybe the doc should include all the necessary setup to run this action against our own repo.
You will need this:

permissions:
  contents: write
  pull-requests: write

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@peter-evans
Copy link
Owner

Hi @wiiznokes

It's good practice to restrict the token's permissions with this block, but it's not necessary for the action to work. These permissions are documented in the inputs table here.

permissions:
  contents: write
  pull-requests: write

You don't need this for the action to work. The action doesn't fetch tokens from environment variables.

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The error Resource not accessible by integration usually occurs because the workflow is being triggered on pull_request by a contribution from a fork. In this case, GITHUB_TOKEN only has read access. There is more info about restrictions on repository forks here.

@wiiznokes
Copy link
Author

Well, in my case, the action started working when i added

permissions:
  contents: write
  pull-requests: write

And it was not a fork, but the action was triggered with on: push: tags:

@peter-evans
Copy link
Owner

It's a good thing that you have the permissions block, so don't remove it. However, my understanding is that it shouldn't be necessary because the token already has permissive access by default.

@wiiznokes
Copy link
Author

Maybe this have change. My repo have restricted access and i don't remember having change that

@peter-evans
Copy link
Owner

Maybe it has changed recently for newly created repos. I just tested by creating a new repo and this setting is enabled by default, which only gives it read permission:

Image

But for my existing repositories the default is read/write.

I will try to find out if this is a new change.

@peter-evans
Copy link
Owner

Found it. It was updated in February last year:
https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/

I'm working on the next major version of this action, and I'm making some documentation updates at the same time. I will improve the docs to make it clear that this permissions block is necessary for new repos.

Thanks for reporting. It's good to get to the bottom of issues like these and improve the docs. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants