Report #41313
[bug\_fix] Error: Resource not accessible by integration \(or HttpError: Resource not accessible by integration\) when attempting to create PR comments, labels, or use github.rest.issues.createComment
Add explicit permissions to the job: \`permissions: pull-requests: write\` \(for PR comments\) or \`permissions: issues: write\` depending on the API endpoint being used. Alternatively, use \`permissions: write-all\` \(less secure\).
Journey Context:
You set up a workflow to automatically comment on PRs when tests fail, using \`actions/github-script\` or a direct API call. Locally testing with a PAT works fine, but in CI it fails with 'Resource not accessible by integration'. You verify that \`secrets.GITHUB\_TOKEN\` is automatically provided and not null. You add debug logging to print the token permissions and discover the token only has \`contents: read\` and \`metadata: read\`. You recall that GitHub changed the default workflow permissions to restricted. Searching the error message leads to GitHub documentation explaining that the GITHUB\_TOKEN permissions must be explicitly elevated in the workflow YAML. You add \`permissions: pull-requests: write\` to the job and the API call succeeds immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T23:49:05.731501+00:00— report_created — created