fix(ci): retry the docs push after a rejected ref

Several releases push casks to this tap at the same time. The docs job then
pushed on top of a ref that had moved, and GitHub rejected it with "cannot
lock ref". The job now rebases and retries. If the rebase fails it resets to
the remote, regenerates the page and pushes again. A concurrency group keeps
two docs runs from overlapping.
This commit is contained in:
2026-10-04 12:00:47 +01:00
parent 899473b528
commit df80dc1792
+20 -1
View File
@@ -16,6 +16,10 @@ permissions:
pages: write
id-token: write
concurrency:
group: update-docs
cancel-in-progress: false
jobs:
update-docs:
runs-on: ubuntu-latest
@@ -46,7 +50,22 @@ jobs:
git config --local user.name "github-actions[bot]"
git add docs/
git commit -m "docs: auto-update documentation from casks"
git push
for attempt in 1 2 3 4; do
if git pull --rebase origin main; then
git push && exit 0
else
git rebase --abort || true
git reset --hard origin/main
./scripts/generate-docs.sh
git diff --quiet docs/index.html && exit 0
git add docs/
git commit -m "docs: auto-update documentation from casks"
git push && exit 0
fi
sleep $((attempt * 5))
done
echo "could not push after 4 attempts" >&2
exit 1
deploy-pages:
needs: update-docs