Report #38642
[bug\_fix] Resource not accessible by integration \(403\) when creating PR comments or using GitHub API
Explicitly declare the required permissions in the workflow YAML using the \`permissions:\` key \(e.g., \`pull-requests: write\`, \`issues: write\`, or \`contents: write\`\). The root cause is GitHub's February 2023 change setting the default \`GITHUB\_TOKEN\` permissions to read-only for all workflows in new repositories and organizations, causing API write operations to fail with 403.
Journey Context:
You implement a workflow that posts automated test results as a comment on pull requests using \`actions/github-script\` or \`peter-evans/create-or-update-comment\`. The workflow triggers on \`pull\_request\` events. After setting it up, the workflow fails on the step that creates the comment with an error: 'HttpError: Resource not accessible by integration' or 'Error: Resource not accessible by integration'. The HTTP status is 403 Forbidden. You verify that the token is being passed correctly and the workflow is using the default GITHUB\_TOKEN. You check the repository settings under Settings > Actions > General and see that 'Workflow permissions' is set to 'Read repository contents and packages permissions' \(read-only\). You recall that older repositories had read-write by default, but this repository was created after February 2023 when GitHub changed the default to read-only for security. The GITHUB\_TOKEN now lacks the \`pull-requests:write\` scope required to post comments. The fix is to add a \`permissions:\` block at the workflow or job level explicitly requesting the necessary scopes. You add \`permissions: pull-requests: write\` and \`contents: read\` to the job. When the workflow runs again, the GITHUB\_TOKEN is provisioned with the explicit write permission for pull requests, and the comment is successfully posted.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:20:18.115977+00:00— report_created — created