Skip to content

Commit a3fed58

Browse files
committed
CI: prevent gh-pages deploy race with force_orphan + concurrency
The v1.2.1 tag push and the same-commit main push triggered the deploy-pages job twice in parallel. They both ran build-html successfully, then both tried to push to gh-pages — one won, the other got 'failed to push some refs (fetch first)'. Two changes: 1. force_orphan: true on the gh-pages action. Each deploy creates a fresh orphan commit instead of fetching and fast-forwarding. No fetch step means no fetch-first conflict. 2. Separate concurrency group 'deploy-pages' for the deploy job (the build concurrency group is keyed on github.ref, so main + tag don't share a group there). Serializes deploys across all refs so future tag-and-main races also self-resolve. This commit itself ships v1.2.1's content (including the new Notice page) to Pages.
1 parent 70d53ca commit a3fed58

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ jobs:
125125
# Deploy on main pushes AND on v* tag pushes, so tagged releases
126126
# also refresh the live site instead of leaving it behind.
127127
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
128+
# Separate from the build concurrency group: serialize deploys
129+
# across all refs so a main-push and a tag-push of the same
130+
# commit don't race for gh-pages.
131+
concurrency:
132+
group: deploy-pages
133+
cancel-in-progress: false
128134
runs-on: ubuntu-latest
129135
steps:
130136
- name: Download HTML artifact
@@ -140,6 +146,10 @@ jobs:
140146
publish_dir: ./site
141147
publish_branch: gh-pages
142148
commit_message: "deploy: ${{ github.sha }}"
149+
# Always create a fresh orphan commit on gh-pages instead
150+
# of trying to merge / fast-forward against whatever's there.
151+
# Makes each deploy atomic and immune to concurrent pushes.
152+
force_orphan: true
143153

144154
release:
145155
name: Create GitHub Release

0 commit comments

Comments
 (0)