-
Notifications
You must be signed in to change notification settings - Fork 175
302 lines (256 loc) · 9.84 KB
/
Copy pathmain.yml
File metadata and controls
302 lines (256 loc) · 9.84 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
name: CI & Book Publication
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb
with:
node-version: '24'
cache: true
run-install: false
- name: Install dependencies (frozen)
run: vp install --frozen-lockfile
- name: Verify
run: vp run check
docs:
runs-on: ubuntu-latest
needs: verify
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb
with:
node-version: '24'
cache: true
run-install: false
- name: Install dependencies (frozen)
run: vp install --frozen-lockfile
- name: Build docs
run: vp run docs:build
- name: Configure Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook'
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b
# NOTE: This artifact is used for GitHub Pages deployment. The repository Pages source
# must be switched from "gh-pages" branch to "GitHub Actions" only after this workflow goes green.
- name: Upload Pages artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook'
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa
with:
path: docs/.vitepress/dist
manifest:
runs-on: ubuntu-latest
needs: verify
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb
with:
node-version: '24'
cache: true
run-install: false
- name: Install dependencies (frozen)
run: vp install --frozen-lockfile
- name: Derive Variables
run: |
echo "BOOK_DATE=$(git log -1 --format=%cs)" >> $GITHUB_ENV
echo "SOURCE_REVISION=${{ github.sha }}" >> $GITHUB_ENV
- name: Assemble book & manifest
run: vp run book:assemble
- name: Upload Manifest and Manuscripts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: manifest-manuscripts
path: |
dist/publication/manifest.json
dist/publication/en/Plurality-english.md
dist/publication/zh-TW/Plurality-traditional-mandarin.md
legacy:
runs-on: ubuntu-latest
needs: manifest
strategy:
matrix:
locale: [en, zh-TW]
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb
with:
node-version: '24'
cache: true
run-install: false
- name: Install dependencies (frozen)
run: vp install --frozen-lockfile
- name: Derive Variables
run: |
echo "BOOK_DATE=$(git log -1 --format=%cs)" >> $GITHUB_ENV
echo "SOURCE_REVISION=${{ github.sha }}" >> $GITHUB_ENV
- name: Render legacy output
run: vp run book:legacy:${{ matrix.locale }}
- name: Upload legacy artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: legacy-${{ matrix.locale }}
path: dist/publication/legacy
legacy-validation:
runs-on: ubuntu-latest
needs: [manifest, legacy]
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb
with:
node-version: '24'
cache: true
run-install: false
- name: Install dependencies (frozen)
run: vp install --frozen-lockfile
- name: Download manifest and manuscripts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: manifest-manuscripts
path: dist/publication
- name: Download legacy artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
pattern: legacy-*
path: dist/publication/legacy
merge-multiple: true
- name: Validate legacy outputs
env:
EXPECTED_SOURCE_REVISION: ${{ github.sha }}
run: vp run book:legacy:validate
candidate:
runs-on: ubuntu-latest
needs: manifest
strategy:
matrix:
locale: [en, zh-TW]
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb
with:
node-version: '24'
cache: true
run-install: false
- name: Install fonts
run: |
sudo apt-get update
sudo apt-get install -y fonts-noto-cjk fonts-noto-color-emoji
- name: Install dependencies (frozen)
run: vp install --frozen-lockfile
- name: Derive Variables
run: |
echo "BOOK_DATE=$(git log -1 --format=%cs)" >> $GITHUB_ENV
echo "SOURCE_REVISION=${{ github.sha }}" >> $GITHUB_ENV
- name: Render candidate output
run: vp run book:candidate:${{ matrix.locale }}
- name: Upload candidate artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: candidate-${{ matrix.locale }}
path: dist/publication/candidate
candidate-validation:
runs-on: ubuntu-latest
needs: [manifest, candidate]
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb
with:
node-version: '24'
cache: true
run-install: false
- name: Install dependencies (frozen)
run: vp install --frozen-lockfile
- name: Download manifest and manuscripts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: manifest-manuscripts
path: dist/publication
- name: Download candidate artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
pattern: candidate-*
path: dist/publication/candidate
merge-multiple: true
- name: Validate candidate outputs
env:
EXPECTED_SOURCE_REVISION: ${{ github.sha }}
run: vp run book:candidate:validate
# NOTE: The GitHub Pages build/deployment source must be switched from the legacy "gh-pages" branch
# to "GitHub Actions" in the repository settings ONLY after this workflow has run successfully and is green.
# DO NOT mutate live Pages settings or push directly.
deploy-pages:
runs-on: ubuntu-latest
needs: docs
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook'
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
release:
runs-on: ubuntu-latest
needs: [legacy-validation, docs]
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Download manifest and manuscripts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: manifest-manuscripts
path: dist/publication
- name: Download legacy artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
pattern: legacy-*
path: dist/publication/legacy
merge-multiple: true
- name: Create or Update GitHub Release
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd
with:
allowUpdates: true
removeArtifacts: false
replacesArtifacts: true
artifactErrorsFailBuild: true
tag: latest
name: "Latest Book Release"
artifacts: "dist/publication/manifest.json,dist/publication/legacy/Plurality-english.pdf,dist/publication/legacy/Plurality-english.epub,dist/publication/legacy/Plurality-traditional-mandarin.pdf,dist/publication/legacy/Plurality-traditional-mandarin.epub"
webhook:
runs-on: ubuntu-latest
needs: [release, deploy-pages]
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook'
steps:
- name: Send Rebuild Webhook
env:
REBUILD_WEBHOOK: ${{ secrets.REBUILD_WEBHOOK }}
run: |
curl --fail-with-body --retry 3 --retry-all-errors -X POST \
-H "Content-Type: application/json" \
-d "{\"revision\":\"${{ github.sha }}\",\"manifest_release_url\":\"https://github.com/${{ github.repository }}/releases/download/latest/manifest.json\",\"release_url\":\"https://github.com/${{ github.repository }}/releases/tag/latest\"}" \
"$REBUILD_WEBHOOK"