Report #14510
[bug\_fix] Resource not accessible by integration or 403 Forbidden when using GITHUB\_TOKEN to comment on PRs, upload artifacts, or push packages on pull requests from forks or Dependabot
Add explicit permissions block at the workflow or job level \(e.g., permissions: pull-requests: write contents: read\) for same-repo PRs. For fork PRs requiring write access, use workflow\_run triggered by the completion of the pull\_request workflow, as fork GITHUB\_TOKENs are strictly read-only.
Journey Context:
Developer notices CI passes on the main branch but fails on external pull requests with 403 errors when attempting to post test results as PR comments. Initially suspecting an expired Personal Access Token, the developer checks repository settings and discovers the default workflow permissions were changed to read-only in February 2023. Attempting to change the global setting to "Read and write permissions" works for internal branches but not for forks due to security restrictions. The developer finally implements an explicit permissions: pull-requests: write block in the workflow YAML for internal PRs, and rearchitects the workflow to use workflow\_run for fork PRs, understanding that this pattern safely handles untrusted code with elevated permissions in a separate privileged workflow that runs after the initial PR workflow completes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:45:40.642706+00:00— report_created — created