Skip to content

Commit 395f918

Browse files
Merge pull request #178 from aligent/fix/vercel-per-project-concurrency-groups
Scope Vercel concurrency groups by project ID
2 parents 42cc1cf + ce4b6bf commit 395f918

4 files changed

Lines changed: 78 additions & 4 deletions

File tree

.github/workflows/vercel-preview.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ on:
2626
description: "Vercel deployment token"
2727
required: true
2828

29+
# Scoped per project so a repo deploying several Vercel projects from one PR
30+
# gets an independent group per project instead of the jobs cancelling each other.
2931
concurrency:
30-
group: vercel-preview-${{ github.event.pull_request.number }}
32+
group: vercel-preview-${{ github.event.pull_request.number }}-${{ inputs.vercel-project-id }}
3133
cancel-in-progress: true
3234

3335
jobs:
@@ -73,6 +75,8 @@ jobs:
7375
echo "inspect_url=$inspect_url" >> "$GITHUB_OUTPUT"
7476
7577
# Posts (or updates in place) a single comment on the PR with the preview URL.
78+
# The marker is scoped per project so each Vercel project keeps its own
79+
# comment rather than overwriting another project's.
7680
- name: Comment preview URL on PR
7781
env:
7882
GH_TOKEN: ${{ github.token }}
@@ -82,7 +86,7 @@ jobs:
8286
INSPECT_URL: ${{ steps.deploy.outputs.inspect_url }}
8387
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
8488
run: |
85-
marker='<!-- vercel-preview -->'
89+
marker="<!-- vercel-preview:${VERCEL_PROJECT_ID} -->"
8690
body="$marker
8791
### ⚡ Preview environment is deploying
8892
@@ -91,7 +95,7 @@ jobs:
9195
**Preview URL:** ${DEPLOY_URL}
9296
**Inspect:** ${INSPECT_URL}
9397
94-
_Deployed commit ${COMMIT_SHA}_"
98+
_Project ${VERCEL_PROJECT_ID}, deployed commit ${COMMIT_SHA}_"
9599
96100
comment_id="$(gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" \
97101
--jq "[.[] | select(.body | startswith(\"${marker}\"))][0].id")"

.github/workflows/vercel-production.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ on:
2626
description: "Vercel deployment token"
2727
required: true
2828

29+
# Scoped per project so a repo deploying several Vercel projects from one push
30+
# gets an independent group per project instead of the jobs queueing behind each other.
2931
concurrency:
30-
group: vercel-production-${{ github.ref }}
32+
group: vercel-production-${{ github.ref }}-${{ inputs.vercel-project-id }}
3133
cancel-in-progress: false
3234

3335
jobs:

docs/vercel-preview.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ pull request with the preview and inspect URLs. Intended to be called from a
1717
|---------------|----------|--------------------------|
1818
| vercel-token || Vercel deployment token |
1919

20+
#### Concurrency
21+
22+
Runs are grouped by pull request **and** `vercel-project-id`, with
23+
`cancel-in-progress: true`. A new commit supersedes the in-flight preview for
24+
that project, while previews for other projects are left alone.
25+
2026
#### Example Usage
2127

2228
```yaml
@@ -34,3 +40,32 @@ jobs:
3440
secrets:
3541
vercel-token: ${{ secrets.VERCEL_TOKEN }}
3642
```
43+
44+
#### Deploying more than one Vercel project
45+
46+
Call the workflow once per project. Give each call a distinct
47+
`environment-name`, otherwise every job writes its deployment status and URL to
48+
the same GitHub Environment and the last one to finish wins.
49+
50+
```yaml
51+
jobs:
52+
deploy-storefront-preview:
53+
uses: aligent/workflows/.github/workflows/vercel-preview.yml@main
54+
with:
55+
vercel-org-id: ${{ vars.VERCEL_ORG_ID }}
56+
vercel-project-id: ${{ vars.VERCEL_PROJECT_ID }}
57+
environment-name: Preview
58+
secrets:
59+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
60+
61+
deploy-admin-preview:
62+
uses: aligent/workflows/.github/workflows/vercel-preview.yml@main
63+
with:
64+
vercel-org-id: ${{ vars.VERCEL_ORG_ID }}
65+
vercel-project-id: ${{ vars.VERCEL_ADMIN_PROJECT_ID }}
66+
environment-name: Preview - admin
67+
secrets:
68+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
69+
```
70+
71+
Each project gets its own PR comment, keyed on the project ID.

docs/vercel-production.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Deploys a production build to Vercel. Intended to be called from a `push` (or
1616
|---------------|----------|--------------------------|
1717
| vercel-token || Vercel deployment token |
1818

19+
#### Concurrency
20+
21+
Runs are grouped by ref **and** `vercel-project-id`, with
22+
`cancel-in-progress: false`. Deploys for the same project queue in order, while
23+
deploys for different projects run in parallel.
24+
1925
#### Example Usage
2026

2127
```yaml
@@ -34,3 +40,30 @@ jobs:
3440
secrets:
3541
vercel-token: ${{ secrets.VERCEL_TOKEN }}
3642
```
43+
44+
#### Deploying more than one Vercel project
45+
46+
Call the workflow once per project. Give each call a distinct
47+
`environment-name`, otherwise every job writes its deployment status and URL to
48+
the same GitHub Environment and the last one to finish wins.
49+
50+
```yaml
51+
jobs:
52+
deploy-storefront-production:
53+
uses: aligent/workflows/.github/workflows/vercel-production.yml@main
54+
with:
55+
vercel-org-id: ${{ vars.VERCEL_ORG_ID }}
56+
vercel-project-id: ${{ vars.VERCEL_PROJECT_ID }}
57+
environment-name: Production
58+
secrets:
59+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
60+
61+
deploy-admin-production:
62+
uses: aligent/workflows/.github/workflows/vercel-production.yml@main
63+
with:
64+
vercel-org-id: ${{ vars.VERCEL_ORG_ID }}
65+
vercel-project-id: ${{ vars.VERCEL_ADMIN_PROJECT_ID }}
66+
environment-name: Production - admin
67+
secrets:
68+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
69+
```

0 commit comments

Comments
 (0)