Skip to content

Commit 7efe69b

Browse files
committed
Publish the branch tip so a cancelling run never deploys older content
With one concurrency group per site, the run that arrives last cancels the one in progress. update-downloads and axe-scan passed the SHA they had just pushed, so a publish queued a few seconds late could cancel a run for a newer commit (a sync PR merged into prerelease meanwhile) and deploy the older SHA. Push-triggered runs had the same exposure through the default checkout of github.sha. Every caller now passes a branch name, and the checkout falls back to github.ref instead of github.sha, so each run builds the branch tip as it stands when the job starts. port-to-prerelease already did this. The commit-hash job outputs that only fed the pinned refs are removed.
1 parent 69946c4 commit 7efe69b

3 files changed

Lines changed: 12 additions & 17 deletions

File tree

‎.github/workflows/axe-scan.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
contents: write # commits _axe-report.md to the branch
4242
outputs:
4343
changes_detected: ${{ steps.auto-commit.outputs.changes_detected }}
44-
commit: ${{ steps.auto-commit.outputs.commit_hash }}
4544
steps:
4645
- name: Check out repository
4746
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -169,7 +168,7 @@ jobs:
169168
contents: read
170169
statuses: write
171170
with:
172-
ref: ${{ needs.scan.outputs.commit }}
171+
ref: ${{ inputs.branch }}
173172
prerelease: ${{ inputs.prerelease }}
174173
secrets:
175174
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

‎.github/workflows/publish.yml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
inputs:
99
ref:
1010
required: true
11-
description: 'The ref to trigger the workflow on'
11+
description: 'The branch to publish; its tip is checked out when the job starts'
1212
type: string
1313
prerelease:
1414
required: true
@@ -28,7 +28,8 @@ permissions:
2828

2929
concurrency:
3030
# One group per deployed site, whichever workflow calls it, so an older
31-
# build cannot finish last and overwrite a newer deploy.
31+
# build cannot finish last and overwrite a newer deploy. Each run checks
32+
# out the branch tip, so the run that wins includes every earlier change.
3233
# Same site selection as the deploy steps: an explicit prerelease input wins
3334
# over the caller's ref.
3435
group: ${{ format('publish - {0}', (inputs.prerelease || (format('{0}', inputs.prerelease) != 'false' && github.ref == 'refs/heads/prerelease')) && 'prerelease' || 'main') }}
@@ -41,8 +42,9 @@ jobs:
4142
- name: Check out repository
4243
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4344
with:
44-
# if called from workflow_call event, checkout the ref otherwise use default
45-
ref: ${{ inputs.ref || '' }}
45+
# The branch tip, not the triggering commit: a run that cancels an
46+
# older one must not deploy older content than it.
47+
ref: ${{ inputs.ref || github.ref }}
4648
persist-credentials: false # deploys with NETLIFY_AUTH_TOKEN, never pushes
4749

4850
- name: Get latest pre-release from github

‎.github/workflows/update-downloads.yml‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
contents: write # commits the regenerated JSON and syncs it to prerelease
1212
outputs:
1313
changes_detected: ${{ steps.auto-commit.outputs.changes_detected }}
14-
commit: ${{ steps.auto-commit.outputs.commit_hash }}
15-
commit_prerelease: ${{ steps.sync-prerelease.outputs.commit_hash }}
1614
prerelease_version: ${{ steps.get-versions.outputs.prerelease_version }}
1715
steps:
1816
- name: Checkout Repo
@@ -49,7 +47,6 @@ jobs:
4947
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
5048

5149
- name: Sync generated downloads to prerelease branch
52-
id: sync-prerelease
5350
if: ${{ steps.auto-commit.outputs.changes_detected == 'true' }}
5451
env:
5552
MAIN_SHA: ${{ steps.auto-commit.outputs.commit_hash }}
@@ -67,11 +64,9 @@ jobs:
6764
git commit -m "Sync generated download redirects from main"
6865
git push origin prerelease
6966
fi
70-
echo "commit_hash=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
7167
72-
# If a new commit has been made with updated downloads,
73-
# then publish the changes using the new commit as ref to checkout
74-
# in the reusable publish workflow
68+
# If a new commit has been made with updated downloads,
69+
# then publish main with the reusable publish workflow
7570
publish-changes-release:
7671
needs: [ update-downloads ]
7772
if: ${{ needs.update-downloads.outputs.changes_detected == 'true' }}
@@ -81,14 +76,13 @@ jobs:
8176
contents: read
8277
statuses: write
8378
with:
84-
ref: ${{ needs.update-downloads.outputs.commit }}
79+
ref: main
8580
prerelease: false
8681
secrets:
8782
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
8883

8984
# If a new commit has been made with updated downloads,
90-
# then publish the changes using the new commit as ref to checkout
91-
# in the reusable publish workflow
85+
# then publish prerelease with the reusable publish workflow
9286
publish-changes-prerelease:
9387
needs: [ update-downloads ]
9488
if: ${{ needs.update-downloads.outputs.changes_detected == 'true' }}
@@ -98,7 +92,7 @@ jobs:
9892
contents: read
9993
statuses: write
10094
with:
101-
ref: ${{ needs.update-downloads.outputs.commit_prerelease }}
95+
ref: prerelease
10296
prerelease: true
10397
secrets:
10498
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

0 commit comments

Comments
 (0)