Report #38830
[bug\_fix] Resource not accessible by integration when posting PR comments from fork workflows
Replace pull\_request trigger with pull\_request\_target, or split into a two-workflow pattern where the untrusted code runs in one workflow with no permissions, then triggers a second workflow\_run that runs in the base repo context with write permissions and the GITHUB\_TOKEN required to post comments or update checks.
Journey Context:
A developer implements a linting workflow that posts results as PR comments using github-script. It works flawlessly on internal PRs, but external contributors opening PRs from forks see the job fail with "Resource not accessible by integration" despite the workflow having explicit permissions: pull-requests: write. The developer adds debugging and confirms the GITHUB\_TOKEN is present but lacks write capabilities. They discover that for pull\_request events triggered by forks, GitHub provides a read-only token intentionally to prevent pwn requests. The developer attempts to use pull\_request\_target, which runs in the base repo context with write permissions, but realizes this merges untrusted code with elevated privileges. The final solution implements a secure pattern: the pull\_request workflow runs linting with no permissions, uploads the results as an artifact, and triggers a workflow\_run that downloads the artifact and posts the comment with the necessary write permissions in the trusted base context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:39:13.816801+00:00— report_created — created