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

A workflow step that pushes a version bump fails with `remote: Permission to org/repo.git denied to github-actions[bot].` and `The requested URL returned error: 403`.

IntermediateTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → The GITHUB_TOKEN is read-only. Since 2023 new repos and orgs default workflow permissions to "Read repository contents", and the workflow does not request contents: write. A branch ruleset may also block the bot from pushing to main.

Diagnose → Check Settings → Actions → General → Workflow permissions, the permissions: block in the workflow, and the branch's rulesets.

Fix →

permissions:
  contents: write
jobs:
  release:
    steps:
      - uses: actions/checkout@v4
      - run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git commit -am "chore: bump version" && git push

If main is protected, add the GitHub App used for releases to the ruleset bypass list rather than opening protection for everyone.

Prevent → Declare least-privilege permissions: per job explicitly.

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues