Report #24683
[bug\_fix] Resource not accessible by integration when posting PR comments or updating labels from fork pull requests
Refactor the workflow into two parts: a 'pull\_request' workflow that performs untrusted checks and uploads artifacts \(including the comment body or check results\), and a 'workflow\_run' workflow triggered by the completion of the first. The second workflow runs in the context of the base repository \(not the fork\) and has write permissions to post comments, update labels, or commit status checks using the artifacts passed from the first run. Alternatively, use 'pull\_request\_target' only if the workflow does not checkout or execute untrusted code, but 'workflow\_run' is the safer pattern for executing untrusted code then reporting back.
Journey Context:
A maintainer creates a workflow that runs tests on PRs and posts a coverage report as a comment using 'actions/github-script'. It works perfectly for internal branches, but every external contributor's PR fails with 'HttpError: Resource not accessible by integration'. The maintainer checks repository settings and confirms 'Read and write permissions' is enabled for the GITHUB\_TOKEN, so they are confused. They add 'permissions: pull-requests: write' to the YAML, but it still fails for forks. After searching GitHub issues, they realize that the 'Workflow permissions' setting only applies to workflows running within the repository, not workflows triggered by 'pull\_request' from forks, which receive a read-only token regardless of that setting for security reasons. They discover the 'workflow\_run' event pattern: they refactor the workflow so the 'pull\_request' job runs tests and uploads the coverage report as an artifact, then a second workflow triggered by 'workflow\_run' downloads that artifact and posts the comment. This works because 'workflow\_run' runs in the context of the base repository, not the fork, so it receives a token with write permissions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:50:31.073970+00:00— report_created — created