-
-
Notifications
You must be signed in to change notification settings - Fork 10
277 lines (231 loc) · 8.69 KB
/
ci.yml
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
name: "CI"
on:
push:
branches:
- main
pull_request:
types:
- opened # default
- reopened # default
- synchronize # default
- labeled # Listen for label changes to re-run the diff job.
- unlabeled # Listen for label changes to re-run the diff job.
workflow_dispatch:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
validate:
name: "🦺 Validation"
uses: TWiStErRob/github-workflows/.github/workflows/validate.yml@1e06403c5d561d70e40109c2701ea3092ca6ded7 # v3
permissions:
contents: read
security-events: write
actions: read
build:
name: "Build GitHub Pages Site"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
with:
submodules: true
- name: "Setup old Ruby."
uses: ruby/setup-ruby@v1
with:
# ruby-version: sources/iconfont/.ruby-version # So checkout is needed.
working-directory: sources/iconfont
bundler-cache: false
cache-version: 0 # Increment this number if you need to re-download cached gems.
- name: "Install fontcustom with all dependencies."
working-directory: sources/iconfont
run: "${GITHUB_WORKSPACE}/.github/workflows/install-fontcustom.sh"
- name: "Build iconfont."
working-directory: sources/iconfont
run: fontcustom compile
- name: "Upload 'iconfont' artifact."
uses: actions/upload-artifact@v4
with:
name: 'iconfont'
if-no-files-found: error
path: |
_sass/_iconfont.scss
assets/fonts/iconfont.eot
assets/fonts/iconfont.svg
assets/fonts/iconfont.ttf
assets/fonts/iconfont.woff
assets/fonts/iconfont.woff2
sources/iconfont/.fontcustom-manifest.json
sources/iconfont/iconfont-preview.html
- name: "Setup Ruby."
uses: ruby/setup-ruby@v1
with:
#ruby-version: .ruby-version # So checkout is needed.
bundler-cache: true
cache-version: 0 # Increment this number if you need to re-download cached gems.
- name: "Retrieve GitHub Pages configuration."
id: pages
uses: actions/configure-pages@v5
- name: "Build _site with Jekyll."
env:
JEKYLL_ENV: production
BASE_URL: "${{ steps.pages.outputs.base_path }}"
run: bundle exec jekyll build --trace --baseurl "${BASE_URL}"
- name: "Upload 'github-pages' artifact."
uses: actions/upload-pages-artifact@v3
with:
path: _site/
deploy:
name: "Deploy GitHub Pages Site"
if: ${{ github.event_name == 'push' }}
needs:
- build
timeout-minutes: 1
permissions:
# actions/deploy-pages
pages: write
# actions/deploy-pages
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: "Deploy to GitHub Pages"
id: deployment
uses: actions/deploy-pages@v4
cache:
name: "Build Reference Site"
if: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'content-change')) || github.event_name == 'push' }}
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: "Calculate relevant SHA."
id: params
env:
SHA: ${{ github.event.pull_request.base.sha || github.event.after }}
run: |
echo "sha=${SHA}" >> "${GITHUB_OUTPUT}"
- name: "Load cached site."
id: cache
uses: actions/cache/restore@v4
with:
key: github-pages-${{ steps.params.outputs.sha }}
path: _site/
# If exists (steps.cache.outputs.cache-hit == 'true'), then skip regeneration steps.
- name: "Checkout ${{ steps.params.outputs.sha }} commit in ${{ github.repository }} repository."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: actions/checkout@v4
with:
submodules: true
ref: ${{ steps.params.outputs.sha }}
- name: "Setup old Ruby."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: ruby/setup-ruby@v1
with:
# ruby-version: sources/iconfont/.ruby-version # So checkout is needed.
working-directory: sources/iconfont
bundler-cache: false
cache-version: 0 # Increment this number if you need to re-download cached gems.
- name: "Install fontcustom with all dependencies."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: sources/iconfont
run: "${GITHUB_WORKSPACE}/.github/workflows/install-fontcustom.sh"
- name: "Build iconfont."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: sources/iconfont
run: fontcustom compile
- name: "Setup Ruby."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: ruby/setup-ruby@v1
with:
#ruby-version: .ruby-version # So checkout is needed.
bundler-cache: true
cache-version: 0 # Increment this number if you need to re-download cached gems.
- name: "Retrieve GitHub Pages configuration."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
id: pages
uses: actions/configure-pages@v5
- name: "Build _site with Jekyll."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
env:
JEKYLL_ENV: production
BASE_URL: "${{ steps.pages.outputs.base_path }}"
run: bundle exec jekyll build --trace --baseurl "${BASE_URL}"
- name: "Upload 'github-pages-base' artifact."
if: ${{ github.event_name == 'pull_request' && (success() || failure()) }}
# Move cached files from cache to artifacts, so they can be used in other jobs.
# It seems the job id/context is used to create the "cache version" and it always mismatches.
#if: steps.cache.outputs.cache-hit != 'true'
uses: actions/upload-artifact@v4
with:
name: 'github-pages-base'
if-no-files-found: error
path: _site/
- name: "Store _site to cache."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
key: ${{ steps.cache.outputs.cache-primary-key }}
path: _site/
diff:
name: "Verify Against Reference Site"
if: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'content-change') }}
needs:
- build
- cache
timeout-minutes: 1
permissions: {} # download-artifact doesn't need a permission.
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: "Download base reference."
uses: actions/download-artifact@v4
with:
name: 'github-pages-base'
path: github-pages-base
- name: "Prepare base for diffing."
working-directory: github-pages-base
run: |
rm assets/fonts/iconfont.eot
rm assets/fonts/iconfont.svg
rm assets/fonts/iconfont.ttf
rm assets/fonts/iconfont.woff
rm assets/fonts/iconfont.woff2
sed -re 's/Last Updated: [0-9]{4}\/[0-9]{2}\/[0-9]{2}//' -i humans.txt
- name: "Download just-built artifact."
uses: actions/download-artifact@v4
with:
name: 'github-pages'
path: github-pages-head
- name: "Prepare head for diffing."
working-directory: github-pages-head
run: |
# This is not a normal artifact. It was produced by actions/upload-pages-artifact and has only a tar file inside.
tar -xf artifact.tar && rm artifact.tar
rm assets/fonts/iconfont.eot
rm assets/fonts/iconfont.svg
rm assets/fonts/iconfont.ttf
rm assets/fonts/iconfont.woff
rm assets/fonts/iconfont.woff2
sed -re 's/Last Updated: [0-9]{4}\/[0-9]{2}\/[0-9]{2}//' -i humans.txt
# assets/fonts/ is excluded, because building fonts is not deterministic.
- name: "Diff head against base."
run: diff --recursive github-pages-base github-pages-head