Report #82928
[bug\_fix] Resource not accessible by integration \(403\) when creating PR comments, releases, or checks from workflows triggered by pull\_request events on fork PRs
Add explicit job-level permissions \(e.g., \`permissions: pull-requests: write\` or \`contents: write\`\) for same-repo PRs; for fork PRs, do NOT use \`pull\_request\_target\` with checkout of untrusted code. Instead, implement a two-workflow pattern: the untrusted \`pull\_request\` workflow builds and uploads an artifact, then triggers a privileged \`workflow\_run\` workflow that downloads the artifact and posts the comment/release with a write-capable token.
Journey Context:
Developer sets up a workflow to post test coverage comments on PRs. It works perfectly for internal team PRs, but external contributor PRs fail with "Resource not accessible by integration". Developer adds \`permissions: write-all\`, still fails. Realizes the job runs with a read-only token because the PR originates from a fork. Finds \`pull\_request\_target\` online and tries it, which fixes the permission but immediately triggers a security alert because it checks out untrusted PR code with a write token. After reading GitHub Security Lab advisories, developer refactors into two workflows: the first runs on \`pull\_request\` \(untrusted, read-only\), uploads results as an artifact; the second runs on \`workflow\_run\` \(trusted, write-capable\), downloads the artifact and posts the comment. This preserves security while granting necessary permissions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:47:18.259420+00:00— report_created — created