forked from DOI-DO/j40-cejst-2
-
-
Notifications
You must be signed in to change notification settings - Fork 2
193 lines (163 loc) · 5.19 KB
/
build-client.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
name: Build Client
on:
push:
branches: [main]
paths:
- ".github/workflows/build-client.yml"
- "client/**/*"
pull_request:
paths:
- ".github/workflows/build-client.yml"
- "client/**/*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
node-version: 18
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: client
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- name: Install
run: npm ci
- name: Build
run: npm run build
env:
# See the client readme for more info on environment variables:
# https://github.com/usds/justice40-tool/blob/main/client/README.md
DATA_SOURCE: cdn
SITE_URL: "${{ vars.SITE_URL }}"
PATH_PREFIX: "${{ vars.PATH_PREFIX }}"
- name: Get directory contents
run: ls -la public
- name: Upload static files as artifact
id: deployment
uses: actions/upload-pages-artifact@v3
with:
path: ./client/public
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: client
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- name: Install
run: npm ci
- name: Unit tests
run: npm test
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: client
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- name: Install
run: npm ci
- name: Lint
run: npm run lint
- name: License Check
run: npm run licenses
# TODO: This was disabled in the original DOI repo. Much of the code here
# is pretty out of date, so it is nowhere near passing a security audit,
# but it would be good to fix that and re-enable this.
#
# - name: Check for security vulnerabilities
# run: npm audit --production
translations:
runs-on: ubuntu-latest
defaults:
run:
working-directory: client
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- name: Install
run: npm ci
- name: Extract English from source code
if: github.event_name == 'pull_request'
run: npm run intl:extract
- uses: stefanzweifel/git-auto-commit-action@v5
id: commit-strings
if: github.event_name == 'pull_request'
with:
commit_message: 'Auto-update en.json from component source code'
file_pattern: 'client/src/intl/en.json'
- uses: thollander/actions-comment-pull-request@v3
if: steps.commit-strings.outputs.changes_detected == 'true'
with:
message: |
:wave: FYI, your PR has been automatically updated with changes to
`client/src/intl/en.json`, which contains all the translatable text
from the application (probably because you made changes to
the text of a component without updating this file).
- name: Check Spanish translations
# TODO: Make this error fatal when we have a strategy for translations!
#
# Right now, we are trying to quickly iterate on this community
# deployment of CEJST and don't have a clear process or strategy around
# how to handle translations. We're keeping this check in so we have an
# eye on what is or isn't translated, but missing or deprecated
# non-English strings should not stop the build and prevent us from
# merging or deploying changes.
continue-on-error: true
run: |
npm run test:intl-translations > output.txt \
|| echo "Error: ${?}" > ./failed
# Make sure you can see the output in the log!
cat output.txt
if [ -f ./failed ]; then
{
echo '⚠️ English and Spanish translations are mismatched.'
echo '<details><summary>Details:</summary>'
echo ''
echo '```'
cat output.txt
echo '```'
echo ''
echo '</details>'
} >> "${GITHUB_STEP_SUMMARY}"
exit 1
else
echo '✅ Translations in good shape.' >> "${GITHUB_STEP_SUMMARY}"
fi
deploy:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- build
- test
- lint
- translations
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4