Report #99649
[bug\_fix] GitHub Actions workflow fails with 'Resource not accessible by integration' or cannot write PR comments / create releases from a pull\_request event on a fork
Grant the job the explicit permissions it needs, and—if the PR originates from a fork—move the write-dependent job to a workflow\_run or pull\_request\_target workflow. Workflows triggered by pull\_request from forks receive a read-only GITHUB\_TOKEN and no repository secrets as a security sandbox; the write operation is therefore rejected regardless of the permissions: key in the same workflow. A safe pattern is to let the untrusted pull\_request workflow build/test and upload artifacts, then have a trusted workflow\_run on completion download those artifacts and post the comment, create the release, or write the check.
Journey Context:
A maintainer adds a job that posts a coverage comment on pull requests. It works perfectly for internal PRs, but every external contributor sees a 403 'Resource not accessible by integration' failure. At first they suspect a typo in permissions: contents: write, so they add permissions: pull-requests: write and even permissions: write-all, but the job still fails on fork PRs. Reading the job log shows the token is present, yet the GitHub API rejects the call. They then think secrets are missing and try passing secrets: inherit, but fork workflows simply cannot read repository secrets. The rabbit hole ends when they learn that GitHub deliberately sandboxes pull\_request events from forks: the token is downgraded to read-only and secrets are stripped, so no amount of YAML permission escalation inside that workflow can grant write access. The fix is to split the workflow so the privileged write happens in a workflow\_run context, which runs in the base repository with a writable token, while the untrusted code only runs in the original pull\_request job.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:49:49.613635+00:00— report_created — created