-
Notifications
You must be signed in to change notification settings - Fork 16.9k
316 lines (269 loc) · 9.48 KB
/
Copy pathci.yml
File metadata and controls
316 lines (269 loc) · 9.48 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: CI
on:
pull_request:
branches:
- production
paths-ignore:
- ".flue/**"
- ".github/workflows/flue-ci.yml"
- ".github/workflows/flue-deploy.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
typos:
name: Typos
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Check for typos
uses: crate-ci/typos@d43b6c087ac471e2ea7b8af622ff15f05c0c365b # v1.50.1
with:
files: src/content/docs src/content/partials src/content/changelog
config: ./_typos.toml
pre-build:
name: Pre Build
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
id: setup-node
with:
node-version: 24.x
cache: pnpm
- name: Check for CRLF line endings
run: |
if git grep -Il $'\r'; then
echo "::error::CRLF line endings detected. Configure your editor to use LF line endings (this repo has an .editorconfig file that most editors respect automatically)."
exit 1
fi
- name: Check for invalid file extensions
run: |
FILES=$(
find src/content \
-type f \
-not -name '*.mdx' \
-not -name '*.md' \
-not -name '*.json' \
-not -name '*.yml' \
-not -name '*.yaml' \
-not -name '*.txt' \
-not -wholename 'src/content/collections/*'
)
if [ -n "$FILES" ]; then
echo "Found files with invalid file extensions:\n\n$FILES"
exit 1
fi
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check Astro and CF Worker
run: pnpm run check
- name: Set up reviewdog
uses: reviewdog/action-setup@d8a7baabd7f3e8544ee4dbde3ee41d0011c3a93f # v1.5.0
with:
reviewdog_version: v0.21.0
- name: Run eslint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm run lint --format eslint-formatter-checkstyle | \
reviewdog -f=checkstyle -name=eslint -reporter=github-pr-review -fail-level=error -filter-mode=nofilter
- name: Check formatting
# The codebase is always fully formatted, so checking all
# prettier-scoped files is equivalent to checking only changed files.
run: pnpm run format:check
- name: Validate redirects
run: pnpm exec tsm bin/validate-redirects.ts
- name: Check component docs reference
run: pnpm exec tsx bin/check-component-docs.ts
- name: Tests
run: pnpm run test:prebuild
build:
name: Build
needs: pre-build
runs-on: ubuntu-latest
outputs:
succeeded: ${{ steps.build.outputs.succeeded }}
permissions:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
id: setup-node
with:
node-version: 24.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Restore Astro cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
node_modules/.astro
key: astro-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.event.pull_request.head.sha || github.sha }}
restore-keys: |
astro-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-
astro-cache-${{ runner.os }}-
- name: Build
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: "--max-old-space-size=8192"
run: |
set -o pipefail
pnpm run build 2>&1 | tee build.log
echo "succeeded=true" >> "$GITHUB_OUTPUT"
- name: Upload build artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: dist
path: dist
- name: Upload build log
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: build-log
path: build.log
if-no-files-found: ignore
post-build:
name: Post Build
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
id: setup-node
with:
node-version: 24.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: dist
path: dist
- name: Tests (Workers)
run: pnpm run test:postbuild
notify:
name: Notify
needs: [pre-build, post-build]
if: always()
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
id: setup-node
with:
node-version: 24.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Post PR CI failure comment
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm exec tsx bin/post-pr-ci-failure-comment/index.ts
publish-preview:
name: Deploy Preview
needs: build
if: github.event.pull_request.head.repo.full_name == github.repository && needs.build.outputs.succeeded == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Set up pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
id: setup-node
with:
node-version: 24.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: dist
path: dist
- name: Deploy to Cloudflare Workers
id: deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
SHORT_SHA="${PR_HEAD_SHA:0:8}"
BRANCH_SLUG=$(echo "$PR_HEAD_REF" | iconv -c -t ascii//TRANSLIT | sed -E 's/[~^]+//g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z)
echo "branch_slug=${BRANCH_SLUG}" >> "$GITHUB_OUTPUT"
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
# These two deploys are independent (different Worker names in the
# same dispatch namespace), so run them concurrently instead of
# back-to-back.
pnpm exec wrangler deploy --config wrangler.preview.json --dispatch-namespace preview-deployments --name "${SHORT_SHA}" &
short_sha_pid=$!
pnpm exec wrangler deploy --config wrangler.preview.json --dispatch-namespace preview-deployments --name "${BRANCH_SLUG}" &
branch_slug_pid=$!
wait "$short_sha_pid"
wait "$branch_slug_pid"
- name: Post preview URL on PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_SLUG: ${{ steps.deploy.outputs.branch_slug }}
SHORT_SHA: ${{ steps.deploy.outputs.short_sha }}
run: pnpm exec tsx bin/post-preview-url-comment/index.ts
continue-on-error: true