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.
2
Answers
It seems that the GitHub Pages repository has different default permission settings. If you add a permission to write to contents, you will be able to push to your repository using GitHub checkout action:
You have to configure your repository –
Settings -> Action -> General -> Workflow permissions
and chooseread and write permissions