Solution to Process completed with exit code 128
on GitHub Actions¶
There are a lot of names this issue might go by:
Process completed with exit code 128
Permission to [username]/[repository].git denied to github-actions[bot].
The requested URL returned error: 403
But they're all the same thing!
The problem¶
If you're running a GitHub Actions scraper, every time you run it you might end up getting an error that looks something like this:
Run git config user.name "Automated"
[main 8611d99] Latest data: Sat Jan 14 22:14:56 UTC 2023
1 file changed, 1 insertion(+), 1 deletion(-)
remote: Permission to jsoma/autoupdating.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/jsoma/autoupdating/': The requested URL returned error: 403
Error: Process completed with exit code 128.
Even if it worked before, it might not work now!
In this case, the problem is that github-actions[bot] is trying to send changes to the repository, but it doesn't have permission to do so.
The solution¶
First, make sure you're using actions/checkout@2
in your steps section. It's older than actions/checkout@v3
, but it's the one that works for me.
Second, add a permissions section with writing enabled. This allows your action to make changes to the repository.
The full workflow file might look something like this. The lines I added or edited are highlighted:
name: scrape
on:
workflow_dispatch:
schedule:
- cron: '*/5 * * * *'
permissions:
contents: write
jobs:
scrape:
runs-on: ubuntu-latest
steps:
- name: Check out this repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install necessary Python packages
run: pip install pandas jupyter lxml playwright beautifulsoup4 requests
- name: Run the scraping script
run: python scraper.py
- name: Commit and push if content changed
run: |-
git config user.name "Automated"
git config user.email "actions@users.noreply.github.com"
git add -A
timestamp=$(date -u)
git commit -m "Latest data: ${timestamp}" || exit 0
git push
What doesn't work¶
One suggestion you'll see is to adding a GITHUB_TOKEN
to the workflow file. This is a token that GitHub Actions automatically generates for you, and it's supposed to give you access to the repository.
Honestly: maybe it's also a solution, I don't know! Generating a token is too complicated to try when there's an easier fix that works perfectly.