Vadik Sirekanyan
Vadik Sirekanyan

Reputation: 4652

Permission denied to github-actions[bot]. The requested URL returned error: 403

I want to push files into the current repository using Github Actions.

I've written a basic configuration that uses the official actions/checkout@v3 action. My configuration is almost the same as in the readme example:

name: Example
on: workflow_dispatch
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - shell: bash
        run: |
          date > 1.txt
          git config user.name github-actions
          git config user.email [email protected]
          git add 1.txt
          git commit -m updated
          git push

This configuration works well for any repository, except Github Pages repository. The error is:

remote: Permission to sirekanian/sirekanian.github.io.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/sirekanian/sirekanian.github.io/': The requested URL returned error: 403
Error: Process completed with exit code 128.

Why GitHub Pages repository differs from the ordinary one? Does the GitHub Pages repository have different permissions that do not allow to push into?

The most similar question I found is How let github actions workflow push generated documentation to other repository in same organization using a bot name. The answer was to use tokens, but I believe I should use a default token.

Upvotes: 44

Views: 20588

Answers (2)

Vadik Sirekanyan
Vadik Sirekanyan

Reputation: 4652

The permissions for GITHUB_TOKEN are read-only by default. If you want to push tags, you need to have write permissions to contents.

If you add a permission to write to contents, you will be able to push to your repository using GitHub checkout action:

name: Example
on: workflow_dispatch
permissions:
  contents: write
jobs:
  # your push job here

Upvotes: 29

Mykola Berezhniuk
Mykola Berezhniuk

Reputation: 1144

You have to configure your repository - Settings -> Action -> General -> Workflow permissions and choose read and write permissions

Upvotes: 60

Related Questions