forked from DOI-DO/j40-cejst-2
-
-
Notifications
You must be signed in to change notification settings - Fork 2
158 lines (133 loc) · 4.07 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
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
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: 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 || echo "Error: ${?}" > ./failed
if [ -f ./failed ]; then
echo "⚠️ Translations: English and Spanish are mismatched." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "See *tranlsations* job logs for details." >> $GITHUB_STEP_SUMMARY
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