Interview Prep/GitHub Actions/Permissions, Tokens & Secrets

`gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable.`

BeginnerTroubleshootingPermissions, Tokens & Secrets
Answer

Likely causes → gh does not pick up the token automatically.

Diagnose → Check the step's env.

Fix →

- run: gh pr comment "$PR" --body "Deployed"
  env:
    GH_TOKEN: ${{ github.token }}
    PR: ${{ github.event.pull_request.number }}

Prevent → Set GH_TOKEN at job level in workflows that use gh heavily.

All GitHub Actions questions Roadmap: GitHub Actions

More on Permissions, Tokens & Secrets