Fix "Resource not accessible by integration" in GitHub Actions
Error: Unhandled error: HttpError: Resource not accessible by integration
- RequestError [HttpError]: Resource not accessible by integration
- remote: Permission to user/repo.git denied to github-actions[bot]. fatal: unable to access 'https://github.com/user/repo/': The requested URL returned error: 403
- Error: Resource not accessible by personal access token
- GitHub Actions is not permitted to create or approve pull requests.
- Error: HttpError: Resource not accessible by integration - https://docs.github.com/rest/issues/comments#create-an-issue-comment
The workflow’s GITHUB_TOKEN is not allowed to make the requested call (comment on a PR, push, create a release…). Declare the needed permissions with a permissions: block in the workflow, for example contents: write or pull-requests: write; for a pull request from a fork, the token stays read-only.
What this error means
Every GitHub Actions run gets a temporary token, GITHUB_TOKEN, issued by the "GitHub Actions" GitHub App: hence the word "integration". Its rights are limited by three things: the repository or organisation setting (read-only by default for repositories created since 2023), the workflow’s permissions: block, and the event context (fork, Dependabot). When an action calls the REST or GraphQL API for an operation those rights do not allow, GitHub answers 403 and the Octokit library prints Resource not accessible by integration. With a fine-grained personal access token, the same problem reads by personal access token.
Common causes
- Read-only token by default: the repository or organisation is set to "Read repository contents and packages permissions".
- Incomplete
permissions:block: as soon as you declare one, every permission not listed becomesnone. - Pull request from a fork or by Dependabot: for the
pull_requestevent, GitHub forces a read-only token, whatever your settings. - Access to another repository:
GITHUB_TOKENonly works for the workflow’s repository; it cannot clone or push to another private repository. - PR creation forbidden: the "Allow GitHub Actions to create and approve pull requests" option is unchecked in the settings.
Step-by-step fix
-
See the token’s actual permissions
In the run log, open the "Set up job" step: the "GITHUB_TOKEN Permissions" section lists the granted rights. Also find which step and which API call failed.
-
Declare permissions in the workflow
This is the right fix: grant at job level only what it needs. Also list
contents: readif the job runs a checkout, because permissions not mentioned becomenone.jobs: comment: runs-on: ubuntu-latest permissions: contents: read pull-requests: write issues: write steps: - uses: actions/checkout@v4 - uses: actions/github-script@v7 with: script: | await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: 'Build OK', }); -
Pick the right permission
contents: writeto push, create a tag or a release;pull-requests: writeto comment on or edit a PR;issues: writefor issues and labels;packages: writeto publish to GHCR;id-token: writefor OIDC authentication to AWS, Azure or GCP;pages: writefor GitHub Pages. -
Check repository and organisation settings
In Settings > Actions > General > Workflow permissions, the organisation setting caps the maximum a workflow can request. Check "Allow GitHub Actions to create and approve pull requests" only if a workflow must open PRs.
-
Forks: split the privileged work
Do not use
pull_request_targetwhile running the PR’s code: a malicious contributor would get a write token and your secrets. Run the tests onpull_request(read-only), then a secondworkflow_runworkflow that posts the comment.on: workflow_run: workflows: ["CI"] types: [completed] permissions: pull-requests: write -
Access to another repository: GitHub App token
Create a GitHub App installed on both repositories, store its ID and private key as secrets, and generate a short-lived token in the workflow. This is safer than a personal token tied to your account.
- uses: actions/create-github-app-token@v1 id: app-token with: app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} - uses: actions/checkout@v4 with: repository: my-org/other-repo token: ${{ steps.app-token.outputs.token }}
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Put
permissions: contents: readat the top of every workflow and grant write access job by job: least privilege. - Also test workflows that comment or push on a PR from a fork before rolling them out on an open source project.
- Prefer GitHub App tokens or OIDC over personal tokens stored as secrets.
Frequently asked questions
Why does it work on my PRs but not on contributors’ ones?
PRs from a fork always get a read-only GITHUB_TOKEN and no access to secrets, so a stranger cannot take over the repository. Use a separate workflow_run workflow for write actions.
Should I check "Read and write permissions" in the settings?
It fixes the error, but gives write access to every workflow. Better keep read-only as the default and add permissions: only to the jobs that need it.
What about "Permission to repo.git denied to github-actions[bot]" on git push?
Same cause: the token lacks contents: write. Add it to the job; if the branch is protected, direct pushes are still refused and you need to open a PR.
Useful tools for this error
More DevOps, servers & cloud errors
- Fix "upstream timed out (110: Connection timed out)" and 504 Gateway Time-out in Nginx
- Fix "nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)"
- Fix "413 Request Entity Too Large" (Nginx, PHP, Express, Cloudflare)
- Fix "Certbot failed to authenticate some domains" (Let’s Encrypt, Timeout during connect, acme-challenge 404)
- Fix the 404 on refresh of a SPA on Vercel ("404: NOT_FOUND"), Netlify and Nginx
- Fix "An error occurred (AccessDenied) when calling the PutObject operation" on AWS S3
- Fix "The connection to the server localhost:8080 was refused" with kubectl