Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

'Resource not accessible by integration' in a GitHub Actions step

ErrorResource not accessible by integration

Short answer

The GITHUB_TOKEN of the run lacks the permission the API call needs. Grant it in the permissions key. On pull requests from forks and Dependabot the token is read-only whatever you write, so label, comment or push from a workflow that runs on pull_request_target or workflow_run, with care.

  • Applies to GitHub Actions, actions/github-script v7
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check which event started the run and which permissions the job has. The same step can pass on a push and fail on a pull request.

    grep -n -E '^on:|pull_request|permissions:' .github/workflows/*.yml
  2. 2Match what you see, then jump to its fix

    1. 1The workflow starts on push or in the same repository, and the call writes (comment, label, release, status)The job does not grant the permission the call needsFix
    2. 2It works on your own branches and fails only on forked or Dependabot pull requestsThe pull request comes from a fork or from DependabotFix
    3. 3The permission is already write and the call still failsThe call needs more than GITHUB_TOKEN can ever haveFix
    4. 4A job with no permissions block fails when it was copied from a repository that had write defaultsWorkflow permissions are set to read-only and the job relies on the defaultFix

What does the error look like?

  • Resource not accessible by integration
  • HttpError: Resource not accessible by integration

Cause 1 of 4

The job does not grant the permission the call needs

1Check

Each permission is read, write or none, and any permission you leave out of a permissions block is none. The repository default can also be restricted to read-only contents and packages.

grep -n -B1 -A6 'permissions:' .github/workflows/*.yml

2Fix

Add the narrowest write permission the call needs, for example pull-requests: write to comment on a PR or issues: write to label an issue.

permissions:
  contents: read
  pull-requests: write

3Verify

Re-run the job; the API call succeeds.

gh run rerun --failed

Confirmed by docs.github.com

Did this fix it?

Cause 2 of 4

The pull request comes from a fork or from Dependabot

1Check

GITHUB_TOKEN has read-only permissions in pull requests from forked repositories, secrets are not passed to the runner, and Dependabot pull requests are treated as forks.

gh pr view PR_NUMBER --json isCrossRepository,author

2Fix

Keep the pull_request workflow for build and tests. Move the write step (label, comment) to a workflow on pull_request_target, which runs in the base repository's context. Never check out or run the pull request's code in that workflow.

on:
  pull_request_target:
    types: [opened]
permissions:
  pull-requests: write
jobs:
  label:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            await github.rest.issues.addLabels({
              owner: context.repo.owner, repo: context.repo.repo,
              issue_number: context.issue.number, labels: ['needs-review']
            })

3Verify

Open a test pull request from a fork and watch the label appear.

gh pr view PR_NUMBER --json labels

Confirmed by docs.github.com

Did this fix it?

Cause 3 of 4

The call needs more than GITHUB_TOKEN can ever have

1Check

The token can only do what its permissions allow. For access beyond that, GitHub suggests a GitHub App installation token, or a personal access token kept as a secret.

grep -n 'secrets\.' .github/workflows/*.yml

2Fix

Create a GitHub App, install it on the repositories you need, and generate an installation token in the job. Use a personal access token only if an App is not an option.

# pass the App token to the step instead of github.token
env:
  GH_TOKEN: ${{ steps.app-token.outputs.token }}

3Verify

The call that failed now returns success.

gh run rerun --failed

Confirmed by docs.github.com

Did this fix it?

Cause 4 of 4

Workflow permissions are set to read-only and the job relies on the default

1Check

A new personal repository gives GITHUB_TOKEN read access for contents and packages only; organizations inherit their own setting. Creating pull requests also has its own switch.

grep -n 'permissions:' .github/workflows/*.yml || echo 'no permissions block: repository default applies'

2Fix

Prefer an explicit permissions block in the workflow. If you need the repository default changed, use Settings, Actions, General, Workflow permissions (and the create-and-approve pull requests box if the job opens PRs).

permissions:
  contents: write

3Verify

Re-run the job; the call that was refused now passes.

gh run rerun --failed

Confirmed by docs.github.com

Did this fix it?

How do I stop it coming back?

  • Write a permissions block on every workflow and give each job only what it uses.
  • Never run code from a fork's pull request in a workflow that has write access.
  • Set the repository default to read-only so missing permissions show up early.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

docker pull or push to ghcr.io fails with 'denied'

Error response from daemon: denied

ghcr.io refuses a pull or push when Docker is not logged in, when the token lacks the package scope, or when the workflow's GITHUB_TOKEN has no packages permission or no access to that package.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.