-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (140 loc) · 4.13 KB
/
build-test-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
name: Build, Test and Deploy Gatsby
on:
pull_request:
push:
branches:
- main
schedule:
# Scheduled build so pipeline failures are noticed quicker.
- cron: "30 4 * * 3,6"
repository_dispatch:
types:
- content-update
jobs:
# Fetch dependencies and build Gatsby
build:
name: Build
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/gh-pages'
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 1
- name: Restore Cached Build
uses: actions/cache@v4
id: cache-public
with:
path: services/personal-website/public
key: build
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Restore node_modules
uses: actions/cache@v4
id: cache-node_modules
with:
key: node_modules-${{ hashFiles('**/package-lock.json') }}
path: |
node_modules
*/*/node_modules
- name: Install Dependencies
run: |
pnpm install --ignore-scripts --filter @alexwilson/personal-website...
- name: Build
run: pnpx lerna run --scope @alexwilson/personal-website build
env:
GITHUB_TOKEN: ${{ secrets.CONTENT_ACCESS_TOKEN }}
CI: true
- name: Save Build Artefact
uses: actions/upload-artifact@v4
with:
name: site-artefact
path: services/personal-website/public
# Run unit tests on the artefact we just built.
test:
name: Test
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 1
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Restore node_modules
uses: actions/cache@v4
id: cache-node_modules
with:
key: node_modules-${{ hashFiles('**/package-lock.json') }}
path: |
node_modules
*/*/node_modules
- name: Install Dependencies
run: |
pnpm install --ignore-scripts --filter @alexwilson/personal-website...
- name: Run Tests
run: pnpx lerna run --scope @alexwilson/personal-website test
validate-feed:
name: "Validate feed"
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@main
with:
repository: w3c/feedvalidator
- uses: actions/setup-python@v5
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Download Website Artefact
uses: actions/download-artifact@v4
with:
name: site-artefact
path: public
- name: "Update feed location for local testing"
run: |
# Replace references to feed IRI with feedvalidator.org which W3C validator uses as a mock origin.
sed -i 's|https://alexwilson.tech/feed.xml|http://www.feedvalidator.org/public/feed.xml|g' public/feed.xml
- name: "Validate Artefacted Feed"
run: |
python src/demo.py public/feed.xml
# Deploy to Github Pages environment
deploy-ghpages:
name: Deploy Gatsby to Github Pages
needs: [test, validate-feed]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 1
- name: Download Website Artefact
uses: actions/download-artifact@v4
with:
name: site-artefact
path: public
- name: Deploy to Github Pages
uses: ./.github/actions/github-pages/
env:
GITHUB_TOKEN: ${{ secrets.PAGES_GH_TOKEN }}
with:
args: public