Interview Prep/GitHub Actions/Secrets, Variables, Environments & Permissions

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.

All GitHub Actions questions Roadmap: GitHub Actions

More on Secrets, Variables, Environments & Permissions