Report #61252
[bug\_fix] Error: Resource not accessible by integration when attempting to create a comment, add a label, or update a check run on a pull request from a forked repository.
Add explicit permissions: pull-requests: write \(and/or issues: write, checks: write\) to the job for internal PRs. For fork PRs, the GITHUB\_TOKEN is restricted to read-only regardless of the permissions block; use the workflow\_run pattern to post comments from a privileged workflow. The error occurs because the token lacks write access to the PR resource.
Journey Context:
You implement a workflow using actions/github-script to post a 'Build succeeded' comment on PRs. It works perfectly when you open a test PR from a branch in the same repo. However, when a contributor opens a PR from their fork, the job fails with 'HttpError: Resource not accessible by integration' at the step where it tries to create the comment. You check the job's GITHUB\_TOKEN Permissions in the logs and see it only has 'Metadata: read' and 'Contents: read', despite your workflow not specifying a permissions block. You add permissions: pull-requests: write issues: write at the job level and test again on a fork PR. It still fails with the same error. You research and discover that for pull\_request events triggered by forks, GitHub explicitly enforces a maximum permission set of read-only for the GITHUB\_TOKEN, regardless of what you specify in the workflow YAML. This is a security measure to prevent malicious PRs from modifying project data. To solve this, you refactor your workflow: the original workflow \(running on pull\_request\) builds the project and uploads the PR number and build output as an artifact. You create a second workflow that triggers on workflow\_run \(completed\), which runs in the context of the base repository \(not the fork\) and has write permissions. This second workflow downloads the artifact and posts the comment using the privileged GITHUB\_TOKEN.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:17:48.123556+00:00— report_created — created