Skip to content

Commit c3ad95d

Browse files
ci: deploy Pages once per merge batch on main (#91)
* ci: deploy Pages once per merge batch on main Skip superseded main pushes after a short settle wait so only the tip builds and deploys, instead of cancelling intermediate Pages runs. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: retrigger CI after Workflow changes note fix Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 74ce5a7 commit c3ad95d

1 file changed

Lines changed: 49 additions & 4 deletions

File tree

‎.github/workflows/pages.yml‎

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,62 @@ name: pages
33
# Builds the documentation site once, verifies that build with
44
# Lighthouse, and deploys the same artifact to GitHub Pages. Repository Settings
55
# → Pages → Source must be "GitHub Actions" (not the legacy /docs folder).
6+
#
7+
# Push bursts on main (a merge-queue batch, or several merges a few seconds
8+
# apart) each fire this workflow. A shared concurrency group would cancel the
9+
# pending middle runs; instead a short settle wait keeps only the tip of main
10+
# building and deploying, and superseded commits exit successfully. The deploy
11+
# job still serializes so two tips never race the Pages backend.
612
on:
713
push:
814
branches: [main]
915
workflow_dispatch:
1016

1117
permissions: {}
1218

13-
concurrency:
14-
group: pages
15-
cancel-in-progress: false
16-
1719
jobs:
20+
tip:
21+
name: batch tip
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 5
24+
permissions:
25+
contents: read
26+
outputs:
27+
deploy: ${{ steps.gate.outputs.deploy }}
28+
steps:
29+
- name: Deploy only the tip of main after a merge batch
30+
id: gate
31+
env:
32+
EVENT_NAME: ${{ github.event_name }}
33+
SHA: ${{ github.sha }}
34+
REPOSITORY: ${{ github.repository }}
35+
GH_TOKEN: ${{ github.token }}
36+
run: |
37+
set -euo pipefail
38+
if [ "$EVENT_NAME" != "push" ]; then
39+
echo "deploy=true" >> "$GITHUB_OUTPUT"
40+
exit 0
41+
fi
42+
# Wait so a merge-queue batch (several pushes within a few seconds)
43+
# settles on one tip; then only that tip builds and deploys.
44+
sleep 60
45+
tip="$(gh api "repos/${REPOSITORY}/commits/main" --jq .sha)"
46+
if [ -z "$tip" ]; then
47+
echo "Could not read the tip of main" >&2
48+
exit 1
49+
fi
50+
if [ "$SHA" = "$tip" ]; then
51+
echo "deploy=true" >> "$GITHUB_OUTPUT"
52+
echo "This commit is the tip of main; continuing."
53+
else
54+
echo "deploy=false" >> "$GITHUB_OUTPUT"
55+
echo "Superseded by ${tip}; skipping Pages for this commit."
56+
fi
57+
1858
build:
1959
name: build site
60+
needs: tip
61+
if: needs.tip.outputs.deploy == 'true'
2062
runs-on: ubuntu-latest
2163
timeout-minutes: 20
2264
permissions:
@@ -97,6 +139,9 @@ jobs:
97139
deploy:
98140
name: Deploy to GitHub Pages
99141
needs: build
142+
concurrency:
143+
group: pages-deploy
144+
cancel-in-progress: false
100145
runs-on: ubuntu-latest
101146
timeout-minutes: 10
102147
permissions:

0 commit comments

Comments
 (0)