Skip to content

Commit e3ef260

Browse files
pfeerickclaude
andcommitted
ci: sync publish workflow from edgetx_2.12 (90592b2)
Brings in per-branch publish concurrency with gh-pages push retry (#35), so this branch's copy matches every other branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a6e1af2 commit e3ef260

1 file changed

Lines changed: 41 additions & 11 deletions

File tree

‎.github/workflows/publish-versioned-docs.yml‎

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ on:
2424
permissions:
2525
contents: write
2626

27-
# Every run rewrites gh-pages and then uploads the whole tree, so run them
28-
# one at a time to avoid racing mike or publishing a stale snapshot.
29-
concurrency:
30-
group: publish-versioned-docs
31-
cancel-in-progress: false
32-
3327
jobs:
3428
publish:
3529
runs-on: ubuntu-latest
3630

31+
# One group per branch. GitHub keeps at most one pending run per group
32+
# and cancels older pending ones, which is harmless here: the newest
33+
# push to a branch already contains the older ones. Different branches
34+
# publish in parallel and retry if another one updates gh-pages first.
35+
concurrency:
36+
group: publish-versioned-docs-${{ github.ref_name }}
37+
cancel-in-progress: false
38+
3739
steps:
3840
- name: Check out source
3941
uses: actions/checkout@v7
@@ -98,17 +100,45 @@ jobs:
98100
env:
99101
# "Edit this page" should open the branch this version is built from.
100102
DOCS_EDIT_URI: edit/${{ github.ref_name }}/website/md-docs/
101-
run: uv run mike deploy --push --update-aliases --title "${{ steps.version.outputs.title }}" ${{ steps.version.outputs.aliases }}
103+
IS_LATEST: ${{ steps.version.outputs.is_latest }}
104+
run: |
105+
# Other branches may push to gh-pages while this one builds. mike's
106+
# push is then rejected as non-fast-forward, so rebuild on top of
107+
# the new tip and try again.
108+
for attempt in 1 2 3 4 5; do
109+
git fetch origin gh-pages
110+
git branch -f gh-pages origin/gh-pages
111+
if uv run mike deploy --push --update-aliases --title "${{ steps.version.outputs.title }}" ${{ steps.version.outputs.aliases }} \
112+
&& { [[ "${IS_LATEST}" != "true" ]] || uv run mike set-default --push latest; }; then
113+
exit 0
114+
fi
115+
echo "gh-pages push failed (attempt ${attempt}), retrying" >&2
116+
sleep $((attempt * 10))
117+
done
118+
exit 1
119+
120+
deploy:
121+
needs: publish
122+
runs-on: ubuntu-latest
102123

103-
- name: Set default docs version
104-
if: steps.version.outputs.is_latest == 'true'
105-
run: uv run mike set-default --push latest
124+
# One group across all branches, so uploads never overlap. If several
125+
# are queued, GitHub keeps only the newest; that's fine because it
126+
# exports gh-pages when it starts, which already includes every
127+
# earlier publish. The last upload is therefore always the newest tree.
128+
concurrency:
129+
group: publish-versioned-docs-cloudflare
130+
cancel-in-progress: false
131+
132+
steps:
133+
- name: Check out source
134+
uses: actions/checkout@v7
106135

107136
- name: Export gh-pages tree for Cloudflare
108137
run: |
138+
git fetch --depth 1 origin gh-pages
109139
rm -rf .site-publish
110140
mkdir .site-publish
111-
git archive gh-pages | tar -x -C .site-publish
141+
git archive FETCH_HEAD | tar -x -C .site-publish
112142
113143
- name: Deploy to Cloudflare Workers
114144
uses: cloudflare/wrangler-action@v4

0 commit comments

Comments
 (0)