Why can `pull_request` workflows from forks not comment on the PR even with `pull-requests: write`?
IntermediateConceptSecrets, Variables, Environments & Permissions
Answer
For fork PRs the GITHUB_TOKEN is forced to read-only regardless of the permissions key (unless the repo setting "Send write tokens to workflows from fork pull requests" is enabled, which is risky). Writes fail with Resource not accessible by integration. Safe pattern: the pull_request job uploads the comment body as an artifact, and a workflow_run workflow in the base context posts it after validating the data.
More on Secrets, Variables, Environments & Permissions
Where can secrets be defined, and what is the precedence?BeginnerHow are secrets protected in transit and in logs, and what are the limits?IntermediateAre secrets available to every step automatically?BeginnerWhy is it a bad idea to store structured data like JSON or a whole `.env` file as one secret?IntermediateWhat is an environment, and which protection rules can it have?BeginnerWhen does a job wait for environment approval, and what does the reviewer see?Intermediate