-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (116 loc) · 3.8 KB
/
Copy pathci.yml
File metadata and controls
122 lines (116 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: CI/CD
on:
push:
branches: [main]
pull_request:
# Cancel superseded runs on the same ref (e.g. rapid pushes to a PR).
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
quality:
name: Lint, Typecheck & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm run test
e2e:
name: Smoke (Playwright)
needs: quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npm run test:e2e
deploy-preview:
name: Deploy Preview
if: github.event_name == 'pull_request'
needs: quality
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
environment:
name: preview
url: ${{ steps.deploy.outputs.url }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
- run: npm install -g vercel@latest
# Remote build: upload source and let Vercel build, instead of uploading a
# large prebuilt bundle. Smaller upload (dodges "Upload aborted") and the
# resulting deployments are redeployable from the Vercel dashboard. The
# url=$(...) assignment fails the step if the deploy errors (no masking).
- name: Deploy
id: deploy
run: |
url=$(vercel deploy --token=${{ secrets.VERCEL_TOKEN }} --yes)
echo "url=$url" >> "$GITHUB_OUTPUT"
- name: Comment preview URL on PR
uses: actions/github-script@v9
with:
script: |
const url = "${{ steps.deploy.outputs.url }}";
const marker = "<!-- vercel-preview -->";
const body = `${marker}\n🔍 **Preview deployment ready:** ${url}\n\n_Commit ${context.sha.slice(0, 7)}_`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find((c) => c.body?.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
deploy-production:
name: Deploy Production
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: quality
runs-on: ubuntu-latest
environment:
name: production
url: ${{ steps.deploy.outputs.url }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
- run: npm install -g vercel@latest
# Remote build (see preview job). url=$(...) fails the step on deploy error.
- name: Deploy
id: deploy
run: |
url=$(vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }} --yes)
echo "url=$url" >> "$GITHUB_OUTPUT"