Report #64157
[bug\_fix] Resource not accessible by integration on fork PR workflows
Replace \`pull\_request\` with \`pull\_request\_target\` event \(with explicit checkout of base SHA to prevent pwn requests\) or split into a two-workflow pattern using \`workflow\_run\`. Root cause: GITHUB\_TOKEN for workflows triggered by fork pull requests is granted read-only permissions to the repository to prevent malicious code from exfiltrating secrets or modifying repository state.
Journey Context:
A maintainer notices that automated PR comment workflows \(like coverage reports or linting feedback\) work perfectly on branches within the repository but fail consistently on external contributor PRs with 'Resource not accessible by integration' or 403 errors when calling \`github.rest.issues.createComment\`. They initially suspect misconfigured repository secrets or organization-level permission blocks. After verifying that the GITHUB\_TOKEN has 'write' permissions configured in the workflow YAML and repository settings, they examine the workflow run logs and notice the token permissions are listed as 'read' despite the configuration. They eventually find documentation explaining that fork PRs receive read-only tokens regardless of settings. They then implement a secure two-workflow architecture: the first workflow \(triggered by pull\_request\) performs untrusted builds and uploads artifacts, while a second workflow \(triggered by workflow\_run\) downloads the artifacts and posts comments using a trusted GITHUB\_TOKEN with write permissions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:10:40.613255+00:00— report_created — created