Skip to content

Commit 1d87b53

Browse files
thodson-usgsclaude
andcommitted
ci(docs): serialize gh-pages deploys to fix the "cannot lock ref" race
Two commits landing on main within a couple of minutes spawn two "Sphinx Docs Build" runs that both force-push gh-pages via JamesIves/github-pages-deploy-action. The newer run reads the gh-pages tip, the older run advances it first, and the newer run's push is then rejected: ! [remote rejected] ... -> gh-pages (cannot lock ref 'refs/heads/gh-pages': is at <new> but expected <old>) The Sphinx build itself succeeds; only the concurrent deploy loses the race. Add a workflow-level concurrency group keyed on the ref so runs targeting the same branch serialize instead of racing. cancel-in-progress is false so every commit's docs still deploy (the later run simply queues behind the earlier one and force-pushes on top). PR builds, which key on their own ref and don't deploy, are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sjb14HkwuCydKSKMsaXsgd
1 parent 018d9c2 commit 1d87b53

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

.github/workflows/sphinx-docs.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ on:
66
push:
77
pull_request:
88

9+
# Serialize runs for the same ref so two near-simultaneous pushes to main
10+
# don't race to force-push gh-pages. Without this, the second deploy fails
11+
# with "cannot lock ref 'refs/heads/gh-pages'" because the first run advanced
12+
# the branch after the second had already read its tip. Queue rather than
13+
# cancel (cancel-in-progress: false) so every commit's docs still deploy.
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: false
17+
918
jobs:
1019
docs:
1120
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)