-
Notifications
You must be signed in to change notification settings - Fork 6
312 lines (265 loc) · 8.84 KB
/
build-deploy.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
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
# NOTE: This depends on AWS resources deployed for the "joshbeard.me" website.
# Refer to https://github.com/joshbeard/joshbeard.me-tf-aws
name: Build
on:
push:
branches:
- master
jobs:
yamllint:
name: YAML Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: resume.yaml
# NOTE: This spell checker only checks the changes *in a commit*. It won't
# scan the whole repo or even a whole file - just what's changed.
# See https://github.com/TypoCI/spellcheck-action
# Another option: https://github.com/check-spelling/check-spelling
spellcheck:
name: Spell Check
runs-on: ubuntu-latest
timeout-minutes: 4
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
ref: ${{ github.ref }}
- name: TypoCheck
uses: typoci/spellcheck-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build Resume
runs-on: ubuntu-latest
needs: [spellcheck, yamllint]
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
ref: ${{ github.ref }}
- name: Generate resume documents from templates (html, md, gemini, txt, json)
run: |
pip install -r requirements.txt
make html md txt gmi json
- name: Upload Markdown Artifact
uses: actions/upload-artifact@master
with:
name: markdown
path: |
README.md
- name: Upload Gemini Artifact
uses: actions/upload-artifact@master
with:
name: gmi
path: |
resume.gmi
- name: Upload Text Artifact
uses: actions/upload-artifact@master
with:
name: txt
path: |
resume.txt
- name: Upload Narrow Text Artifact
uses: actions/upload-artifact@master
with:
name: narrow_txt
path: |
resume-narrow.txt
- name: Upload JSON Artifact
uses: actions/upload-artifact@master
with:
name: json
path: |
resume.json
- name: Add man page frontmatter
run: >
_DATE=$(date "+%B %Y")
echo "% JoshBeard(7) joshbeard.me\n% Josh Beard ([email protected])\n% ${_DATE}\n\n" | cat - README.md > README.man.md
- name: Generate man page
uses: docker://pandoc/latex
with:
args: >
--from markdown --to man
-s README.man.md -o joshbeard-resume.7
- name: Upload man page artifact
uses: actions/upload-artifact@master
with:
name: man
path: |
joshbeard-resume.7
- name: Generate Word Document
uses: docker://pandoc/latex
with:
args: >
--from markdown --to docx README.md
-f gfm
-o dist/Josh-Beard-Resume.docx
- name: Upload Word Artifact
uses: actions/upload-artifact@master
with:
name: word
path: |
dist/Josh-Beard-Resume.docx
- name: Generate PDF Document
uses: browser-actions/setup-chrome@latest
- run: >
chrome
-headless
-disable-gpu
--no-sandbox
--print-to-pdf=dist/Josh-Beard-Resume.pdf
--print-to-pdf-no-header
dist/index.html
- name: Upload PDF Artifact
uses: actions/upload-artifact@master
with:
name: pdf
path: |
dist/Josh-Beard-Resume.pdf
- name: Minify Action
uses: anthonyftwang/[email protected]
- name: Copy artifacts into dist
run: |
cp joshbeard-resume.7 resume.txt resume-narrow.txt resume.json dist
- uses: actions/upload-artifact@master
name: Upload Resume Artifacts
with:
name: src
path: |
dist/
validate:
name: HTML Validation
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
ref: ${{ github.ref }}
- uses: actions/download-artifact@master
name: Download Resume Artifacts
with:
name: src
path: _site
- name: HTML Validation
uses: Cyb3r-Jak3/[email protected]
with:
root: _site
add-markdown:
name: Commit and add Markdown Resume
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
ref: ${{ github.ref }}
- uses: actions/download-artifact@master
name: Download Resume Artifacts
with:
name: markdown
path: .
- name: Debug
run: |
ls
git status
- name: Commit Markdown
uses: EndBug/add-and-commit@v9
with:
author_name: Josh Beard
author_email: [email protected]
message: 'Generated Markdown Resume'
add: 'README.md'
local-deploy:
name: Deploy locally
runs-on: self-hosted
needs: validate
if: "!contains(github.event.head_commit.message, '[skip deploy]')"
steps:
- uses: actions/download-artifact@master
with:
name: gmi
- uses: actions/download-artifact@master
with:
name: txt
- uses: actions/download-artifact@master
with:
name: pdf
- uses: actions/download-artifact@master
with:
name: word
- uses: actions/download-artifact@master
with:
name: man
- name: Deploy resume to Gemini server
id: deploy
uses: Pendect/[email protected]
env:
DEPLOY_KEY: ${{secrets.DEPLOY_KEY}}
with:
flags: '-rv'
options: '--chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r'
ssh_options: ''
src: '.'
dest: '${{ secrets.DEPLOY_USER }}@${{ secrets.LOCAL_GEMINI_SERVER }}:${{ secrets.DEPLOY_PATH }}/'
- name: Display status from deploy
run: echo "${{ steps.deploy.outputs.status }}"
- uses: actions/download-artifact@master
with:
name: narrow_txt
- name: Deploy resume to Gopher server
id: deploy_gopher
uses: Pendect/[email protected]
env:
DEPLOY_KEY: ${{secrets.DEPLOY_KEY}}
with:
flags: '-rv'
options: '--chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r'
ssh_options: ''
src: 'resume-narrow.txt'
dest: '${{ secrets.DEPLOY_USER }}@${{ secrets.LOCAL_GEMINI_SERVER }}:${{ secrets.GOPHER_DEPLOY_PATH }}/resume.txt'
- name: Display status from deploy
run: echo "${{ steps.deploy_gopher.outputs.status }}"
deploy:
name: Deploy Resume Website
runs-on: ubuntu-latest
needs: validate
if: "!contains(github.event.head_commit.message, '[skip deploy]')"
steps:
- uses: actions/download-artifact@master
with:
name: src
- name: Upload to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete --cache-control max-age=604800
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-2'
SOURCE_DIR: '.'
DEST_DIR: "resume"
- name: Set up aws-cli
uses: hsupu/setup-awscli@v1
- name: Set cache on S3 objects
run: |
ls
aws s3 cp s3://s3-website-joshbeard-me/resume/assets/ s3://s3-website-joshbeard-me/resume/assets/ --recursive --acl public-read --cache-control max-age=15552000
for f in index.html Josh-Beard-Resume.pdf Josh-Beard-Resume.docx resume.txt resume-narrow.txt resume.json; do
aws s3 cp s3://${{ secrets.AWS_S3_BUCKET }}/resume/${f} s3://${{ secrets.AWS_S3_BUCKET }}/resume/ --acl public-read --cache-control max-age=604800
done
env:
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'us-west-2'
- name: Invalidate CloudFront Cache
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.CF_DISTRIBUTION }}
PATHS: "/resume*"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}