Interview Prep/Git & GitHub/GitHub, Actions and Pull Request Issues

An action fails with `HttpError: Resource not accessible by integration` (403) when commenting on a PR or adding a label.

IntermediateTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → The GITHUB_TOKEN lacks the needed permission (pull-requests: write, issues: write), the workflow sets a restrictive permissions: block, or the run comes from a fork or Dependabot with a read-only token.

Diagnose → In the run logs, expand "Set up job" → "GITHUB_TOKEN Permissions" to see what was granted.

Fix →

permissions:
  contents: read
  pull-requests: write
  issues: write

For fork PRs, move the commenting to a workflow_run workflow triggered after the CI run.

Prevent → Declare permissions per job and check the "GITHUB_TOKEN Permissions" log section when debugging 403s.

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues