I have the following Github action on my repo. (For the sake of the example,) I want my workflow to add a git notes
on the commit pushed (i.e. run git notes add -m "foo bar"
).
However, I get the following error:
fatal: update_ref failed for ref
refs/notes/commits
: cannot lock refrefs/notes/commits
: Unable to create/home/runner/work/repo_name/repo_name/.git/refs/notes/commits.lock
: Permission denied
What I've tried so far:
- I thought using the
${{ github.token }}
would help, but it isn't. - I made sure to set “Read and Write permissions” in the repo's Settings/Actions/General/Workflow permissions.
- It is also not a
chmod +x
issue, as I'm running the command directly. - Setting the workflow permissions to
write-all
(as suggested by Azeem doesn't solve it either.
Could this be a concurrency issue?
Github Action YAML file:
name: Notes
on:
workflow_dispatch:
permissions: write-all
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ github.token }}
- name: Add git notes
id: git-notes
run: |
git config user.name "Github Actions"
git config user.email "bot@github.actions"
git notes add -m "foo bar"
env:
GITHUB_TOKEN: ${{ github.token }}
Log:
Run git config user.name "Github Actions"
git config user.name "Github Actions"
git config user.email "bot@github.actions"
git notes add --allow-empty -m "foo bar"
shell: /usr/bin/bash -e {0}
env:
GITHUB_TOKEN: ***
Removing note for object HEAD
fatal: update_ref failed for ref 'refs/notes/commits': cannot lock ref 'refs/notes/commits': Unable to create '/home/runner/work/marion_test_notes/marion_test_notes/.git/refs/notes/commits.lock': Permission denied
Error: Process completed with exit code 128.