-
Notifications
You must be signed in to change notification settings - Fork 166
283 lines (228 loc) · 8.07 KB
/
ci.yaml
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
name: sorg CI
env:
# Saw build failures, apparently because awscli is trying to determine
# region. This is an undocumented env var that disables that check.
#
# Discovered from: https://github.com/aws/aws-cli/issues/5262#issuecomment-705832151
AWS_EC2_METADATA_DISABLED: true
CONCURRENCY: 10 # reduced because I think I'm running into Dropbox rate problems
ENABLE_GOAT_COUNTER: true
GOOGLE_ANALYTICS_ID: UA-47798518-1
# Paths for various manually installed utilities. Don't try to use $HOME
# because GitHub Actions won't support it.
MAGICK_BIN: /home/runner/imagemagick/bin/magick
MOZJPEG_BIN: /opt/mozjpeg/bin/cjpeg
PNGQUANT_BIN: /usr/bin/pngquant
on:
pull_request:
push:
schedule:
# Once a week on Tuesday.
- cron: "0 0 * * TUE"
jobs:
check_and_test:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
cache: true
check-latest: true
go-version-file: "go.mod"
# It'd be nice to take apt-get back out of the flow since it's so slow,
# but we seem to need it for a few things:
#
# * pngquant has no particularly easy alternative install options.
#
# * WebPs are run through `cbwebp` (which comes from the webp package)
# by ImageMagick.
#
- name: Install PNGQuant + WebP
run: sudo apt-get install pngquant webp
# The copy of ImageMagick we could get from apt-get is ancient and
# doesn't handle niceties like `.heic` files, so here we get a binary
# directly. When Ubuntu is upgraded at some point in the probably-distant
# future, we can probably get rid of this.
- name: Install ImageMagick
run: |
mkdir -p $(dirname "${{ env.MAGICK_BIN }}")
curl --compressed -L -o "${{ env.MAGICK_BIN }}" https://imagemagick.org/archive/binaries/magick
chmod +x "${{ env.MAGICK_BIN }}"
- name: ImageMagick format options
run: ${{ env.MAGICK_BIN }} identify -list format
# Uses an artifact built by:
#
# https://github.com/brandur/mozjpeg-builder
- name: Install MozJPEG
run: |
curl --compressed -L -O https://github.com/brandur/mozjpeg-builder/releases/download/master/mozjpeg_amd64.deb
sudo dpkg -i mozjpeg_amd64.deb
- name: Debug
run: |
echo "github.ref=${{ github.ref }}"
echo "go env GOPATH=$(go env GOPATH)"
echo "pwd=$(pwd)"
echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}"
echo "HOME=${HOME}"
- name: Clean
run: make clean
- name: "Go: Install"
run: make install
- name: "Go: Test"
run: make test
env:
# GitHub basically makes it fucking impossible to use any kind of
# $HOME variable here for reasons that are far beyond me. Eventually
# just gave up and hard-coded `/home/runner`.
MAGICK_BIN: /home/runner/imagemagick/bin/magick
MOZJPEG_BIN: /opt/mozjpeg/bin/cjpeg
PNGQUANT_BIN: /usr/bin/pngquant
- name: "Check: Dropbox image ?dl=0"
run: make check-dl0
- name: "Check: Gofmt"
run: make check-gofmt
- name: "Check: Markdown headers"
run: make check-headers
- name: "Check: Retina assets"
run: make check-retina
check_tailwind:
runs-on: ubuntu-latest
timeout-minutes: 3
env:
TAILWIND_VERSION: v3.4.15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Tailwind
run: |
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAILWIND_VERSION }}/tailwindcss-linux-x64
mv tailwindcss-linux-x64 tailwindcss
chmod +x tailwindcss
- name: Generate Tailwind
run: |
./tailwindcss -i ./content/stylesheets/tailwind_base.css -o ./content/stylesheets/tailwind.css
./tailwindcss -i ./content/stylesheets/tailwind_base.css -o ./content/stylesheets/tailwind.min.css --minify
- name: Check Git diff
run: |
echo "Please make sure that all Tailwind changes are checked in!"
git diff --exit-code .
deploy_dev:
runs-on: ubuntu-latest
timeout-minutes: 20
if: github.ref == 'refs/heads/master'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWSAccessKeyID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWSSecretAccessKey }}
needs:
- check_and_test
- check_tailwind
- golangci-lint
steps:
# See notes in check_and_test.
- name: Install PNGQuant + WebP
run: sudo apt-get install pngquant webp
# See notes in check_and_test.
- name: Install ImageMagick
run: |
mkdir -p $(dirname "${{ env.MAGICK_BIN }}")
curl --compressed -L -o "${{ env.MAGICK_BIN }}" https://imagemagick.org/archive/binaries/magick
chmod +x "${{ env.MAGICK_BIN }}"
# See notes in check_and_test.
- name: Install MozJPEG
run: |
curl --compressed -L -O https://github.com/brandur/mozjpeg-builder/releases/download/master/mozjpeg_amd64.deb
sudo dpkg -i mozjpeg_amd64.deb
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
cache: true
check-latest: true
go-version-file: "go.mod"
- name: "Sorg: Install"
run: make install
# Download any markers that have not yet been committed to Git to save
# redoing download/resize work.
- name: "Download photo markers"
run: make photographs-download-markers
- name: "Build: Development"
run: make build
env:
DRAFTS: true
TARGET_DIR: ./public-dev
- name: "Deploy: Development"
run: make deploy
env:
S3_BUCKET: brandur.org-dev
TARGET_DIR: ./public-dev
deploy_prod:
runs-on: ubuntu-latest
timeout-minutes: 20
if: github.ref == 'refs/heads/master'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWSAccessKeyID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWSSecretAccessKey }}
needs:
- check_and_test
- check_tailwind
- golangci-lint
steps:
# See notes in check_and_test.
- name: Install PNGQuant + WebP
run: sudo apt-get install pngquant webp
# See notes in check_and_test.
- name: Install ImageMagick
run: |
mkdir -p $(dirname "${{ env.MAGICK_BIN }}")
curl --compressed -L -o "${{ env.MAGICK_BIN }}" https://imagemagick.org/archive/binaries/magick
chmod +x "${{ env.MAGICK_BIN }}"
# See notes in check_and_test.
- name: Install MozJPEG
run: |
curl --compressed -L -O https://github.com/brandur/mozjpeg-builder/releases/download/master/mozjpeg_amd64.deb
sudo dpkg -i mozjpeg_amd64.deb
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
cache: true
check-latest: true
go-version-file: "go.mod"
- name: "Go: Install"
run: make install
# Download any markers that have not yet been committed to Git to save
# redoing download/resize work.
- name: "Download photo markers"
run: make photographs-download-markers
- name: "Build: Production"
run: make build
env:
TARGET_DIR: ./public
- name: "Deploy: Production"
run: make deploy
env:
S3_BUCKET: brandur.org
TARGET_DIR: ./public
- name: Upload photos
run: make photographs-upload
golangci-lint:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
cache: true
check-latest: true
go-version-file: "go.mod"
- name: "Check: golangci-lint"
uses: golangci/golangci-lint-action@v3
with:
version: v1.61