Skip to content

Commit a4ff8bc

Browse files
authored
ci: add concurrency groups to prevent deployment race conditions (#92)
Without concurrency groups, multiple workflow runs triggered by rapid successive pushes can overlap. For the merge workflow, a slower build of an older commit could finish after a newer one, deploying stale code to mlab-oti. For the PR workflow, redundant builds waste CI minutes. - Merge workflow: uses github.ref (the main branch) so only the latest push to main proceeds to production deployment. - PR workflow: uses github.head_ref (the PR branch name) with a fallback to github.run_id, so only the latest push to a given PR branch triggers a preview deployment. cancel-in-progress: true cancels any in-flight run when a newer one starts.
1 parent 4b9602a commit a4ff8bc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.github/workflows/firebase-hosting-merge.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ name: Deploy to Firebase Hosting on merge
66
push:
77
branches:
88
- main
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
913
permissions:
1014
contents: read
1115
checks: write

.github/workflows/firebase-hosting-pull-request.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
name: Deploy to Firebase Hosting on PR
55
'on': pull_request
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
610
permissions:
711
contents: read
812
checks: write

0 commit comments

Comments
 (0)