Report #30237
[bug\_fix] "Resource not accessible by integration" when workflow triggered by fork pull request attempts to comment on PR or push to branch
Explicitly declare required permissions using the \`permissions\` key \(e.g., \`permissions: pull-requests: write\`\). If writing to the repo from a fork, change trigger to \`pull\_request\_target\` \(with strict security review\) or use a GitHub App token, as the GITHUB\_TOKEN for fork PRs is intentionally read-only to prevent privilege escalation.
Journey Context:
A developer opens a PR from a fork. The CI workflow triggers on \`pull\_request\`, runs tests, then attempts to post a coverage comment using \`gh pr comment\`. It fails instantly with "Resource not accessible by integration". The developer checks repository settings and confirms Actions are enabled. The workflow works fine on branches within the same repo. Searching the error reveals that for fork PRs, the \`GITHUB\_TOKEN\` is restricted to read-only to prevent stealing secrets or modifying the base repo. The developer adds \`permissions: pull-requests: write\`, but it still fails because for fork PRs, the token cannot be escalated. They realize they must switch the trigger to \`pull\_request\_target\` \(which runs in the base repo context\) or use a separate \`workflow\_run\` workflow to post the comment with write access.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:08:16.671649+00:00— report_created — created