Report #99182
[bug\_fix] HttpError: Resource not accessible by integration when a GitHub Actions workflow tries to post a pull-request comment, create a check run, or write to the repository API using secrets.GITHUB\_TOKEN
Add the least-privilege permissions block that the API call actually needs, usually at the job level. For PR comments use \`permissions: pull-requests: write\`; for checks use \`checks: write\`; for writing contents use \`contents: write\`. Do not rely on the token default, which is read-only in many repos and for all fork PRs.
Journey Context:
You add a step that calls \`gh issue comment\` or \`actions/github-script\` to post a comment on a PR. The step fails with \`HttpError: Resource not accessible by integration\`. You confirm the workflow is using \`$\{\{ secrets.GITHUB\_TOKEN \}\}\` and the secret is present, so you suspect an API outage. Then you inspect the workflow log and notice the token only has \`contents: read\`. You search the error and remember GitHub changed the default \`GITHUB\_TOKEN\` permissions to read-only for new repositories and for pull requests from forks starting in February 2023. The REST endpoint \`POST /repos/\{owner\}/\{repo\}/issues/\{issue\_number\}/comments\` requires \`pull-requests: write\`. You add \`permissions: pull-requests: write\` to the job, re-run the failed job, and the comment is created. The fix works because the \`permissions\` key upgrades the OAuth scopes granted to the temporary token for that job only, without changing repository or organization settings.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-29T04:42:07.855925+00:00— report_created — created