@@ -3,11 +3,41 @@ name: Build
3
3
on : [push]
4
4
5
5
jobs :
6
+ config :
7
+ runs-on : ubuntu-latest
8
+ outputs :
9
+ canUseSauce : ${{ steps.check_sauce_access.outputs.result == 'true' }}
10
+ tag : ${{ steps.extract_tag.outputs.result }}
11
+ isMainBranch : ${{ github.ref == 'refs/heads/master' }}
12
+ steps :
13
+ - name : check sauce access
14
+ id : check_sauce_access
15
+ run : |
16
+ if ! [[ -z "$SAUCE_USERNAME" ]] && ! [[ -z "$SAUCE_ACCESS_KEY" ]]; then
17
+ echo "::set-output name=result::true"
18
+ fi
19
+ env :
20
+ CI : true
21
+ SAUCE_USERNAME : ${{ secrets.SAUCE_USERNAME }}
22
+ SAUCE_ACCESS_KEY : ${{ secrets.SAUCE_ACCESS_KEY }}
23
+ - name : extract tag
24
+ id : extract_tag
25
+ uses : actions/github-script@v3
26
+ with :
27
+ script : |
28
+ const prefix = '/refs/tags/';
29
+ const ref = context.payload.ref;
30
+ return ref.startsWith(prefix) ? ref.substring(prefix.length) : '';
31
+ result-encoding : string
32
+
6
33
build :
34
+ needs : config
7
35
runs-on : ubuntu-latest
8
36
9
37
steps :
10
38
- uses : actions/checkout@v2
39
+ with :
40
+ fetch-depth : 0
11
41
12
42
- name : cache node_modules
13
43
uses : actions/cache@v2
26
56
with :
27
57
node-version : " 12"
28
58
29
- - name : install and build
59
+ - name : install
30
60
run : |
31
61
npm ci
62
+ env :
63
+ CI : true
64
+
65
+ - name : set version
66
+ run : |
67
+ node ./scripts/set-package-version.js
68
+ env :
69
+ CI : true
70
+ TAG : ${{ needs.config.outputs.tag }}
71
+
72
+ - name : build
73
+ run : |
32
74
npm run lint
33
75
npm run type-check
34
76
npm run build
@@ -76,15 +118,70 @@ jobs:
76
118
with :
77
119
name : build
78
120
79
- - name : run unit tests
121
+ - name : install
80
122
run : |
81
123
npm ci
124
+ env :
125
+ CI : true
126
+
127
+ - name : run unit tests
128
+ run : |
82
129
npm run test:unit
83
130
env :
84
131
CI : true
85
132
133
+ netlify :
134
+ needs : [config, test_unit]
135
+ if : needs.config.outputs.tag || needs.config.outputs.isMainBranch == 'true'
136
+ runs-on : ubuntu-latest
137
+ steps :
138
+ - uses : actions/checkout@v2
139
+
140
+ - name : cache node_modules
141
+ uses : actions/cache@v2
142
+ env :
143
+ cache-name : cache-node-modules
144
+ with :
145
+ path : ~/.npm
146
+ key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
147
+ restore-keys : |
148
+ ${{ runner.os }}-build-${{ env.cache-name }}-
149
+ ${{ runner.os }}-build-
150
+ ${{ runner.os }}-
151
+
152
+ - name : use Node.js
153
+ uses : actions/setup-node@v1
154
+ with :
155
+ node-version : " 12"
156
+
157
+ - name : download build
158
+ uses : actions/download-artifact@v2
159
+ with :
160
+ name : build
161
+
162
+ - name : install
163
+ run : |
164
+ npm ci
165
+ env :
166
+ CI : true
167
+
168
+ - name : build netlify
169
+ run : |
170
+ ./scripts/build-netlify.sh
171
+ env :
172
+ CI : true
173
+
174
+ - name : deploy netlify
175
+ run : |
176
+ ./scripts/deploy-netlify.sh
177
+ env :
178
+ CI : true
179
+ GITHUB_TOKEN : ${{ secrets.CI_GITHUB_TOKEN }}
180
+ NETLIFY_ACCESS_TOKEN : ${{ secrets.NETLIFY_ACCESS_TOKEN }}
181
+
86
182
test_functional_required :
87
- needs : test_unit
183
+ needs : [config, test_unit]
184
+ if : needs.config.outputs.canUseSauce == 'true'
88
185
runs-on : ubuntu-latest
89
186
strategy :
90
187
fail-fast : true
@@ -129,9 +226,14 @@ jobs:
129
226
accessKey : ${{ secrets.SAUCE_ACCESS_KEY }}
130
227
tunnelIdentifier : ${{ github.run_id }}-${{ matrix.config }}
131
228
132
- - name : run functional tests
229
+ - name : install
133
230
run : |
134
231
npm ci
232
+ env :
233
+ CI : true
234
+
235
+ - name : run functional tests
236
+ run : |
135
237
npm run test:func
136
238
env :
137
239
CI : true
@@ -218,9 +320,14 @@ jobs:
218
320
accessKey : ${{ secrets.SAUCE_ACCESS_KEY }}
219
321
tunnelIdentifier : ${{ github.run_id }}-${{ matrix.config }}
220
322
221
- - name : run functional tests
323
+ - name : install
222
324
run : |
223
325
npm ci
326
+ env :
327
+ CI : true
328
+
329
+ - name : run functional tests
330
+ run : |
224
331
npm run test:func
225
332
env :
226
333
CI : true
0 commit comments