CI/CD pipeline - git lfs unlock is returning "Access forbidden. Check your access level."

,

I am attempting to make a job that will release LFS locks on files that are being committed to the default branch. This job is to catch the case where people forget to unlock the files after the MR is merged. Is it possible to give the CI/CD job the permissions to unlock LFS files?

Job:

gitlocks:release:protected:
stage: gitlocks
script:
- files_in_commit=$(git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHA)
- |
for file_in_commit in $files_in_commit; do
echo “Examining $file_in_commit”
is_locked=$(git lfs locks -p $file_in_commit)
if [ “$is_locked” != “” ]; then
echo “Unlocking $file_in_commit - git lfs unlock $file_in_commit”
unlocked=$(git lfs unlock $file_in_commit);
echo “$unlocked”
fi
done
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Output:

Executing “step_script” stage of the job script
$ files_in_commit=$(git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHA)
$ for file_in_commit in $files_in_commit; do # collapsed multi-line command
Examining .gitlab-ci.yml
Examining Assets/Scenes/SampleScene.unity
Unlocking Assets/Scenes/SampleScene.unity - git lfs unlock Assets/Scenes/SampleScene.unity
Access forbidden. Check your access level.