1
1
---
2
- name : Deploy
2
+ name : Deployment
3
3
on :
4
4
workflow_dispatch :
5
5
inputs :
6
6
env :
7
- description : " Deploy to (dev|prod|dev prod)"
7
+ description : ' Deploy to (dev|prod|dev prod)'
8
8
required : true
9
- default : " dev"
9
+ default : ' dev'
10
10
clean :
11
- description : " Clean cache (yes|no)"
11
+ description : ' Clean cache (yes|no)'
12
12
required : true
13
- default : " no "
13
+ default : ' no '
14
14
excludeSubfolder :
15
- description : " Exclude a subfolder from deletion"
15
+ description : ' Exclude a subfolder from deletion'
16
16
required : false
17
- default : " "
17
+ default : ' '
18
18
jobs :
19
19
set-state :
20
20
runs-on : ubuntu-latest
21
21
outputs :
22
22
deploy_prod : ${{ contains(github.event.inputs.env, 'prod') }}
23
23
deploy_dev : ${{ contains(github.event.inputs.env, 'dev') }}
24
24
clean_cache : ${{ contains(github.event.inputs.clean, 'yes') }}
25
- branch_short_ref : ${{ steps.extract_branch.outputs.branch }}
25
+ path_prefix : ${{ steps.get_path_prefix.outputs.path_prefix }}
26
+ branch_short_ref : ${{ steps.get_branch.outputs.branch }}
26
27
exclude_subfolder : ${{ github.event.inputs.excludeSubfolder }}
27
- path_prefix : ${{ steps.extract_pathPrefix.outputs.result }}
28
28
steps :
29
29
- name : Checkout
30
30
uses : actions/checkout@v3
31
- - name : Extract path prefix
31
+
32
+ - name : Get pathPrefix
32
33
uses : actions/github-script@v6
33
- id : extract_pathPrefix
34
+ id : get_path_prefix
34
35
with :
35
36
script : |
36
- const { GITHUB_WORKSPACE } = process.env;
37
- const { pathPrefix } = await require(`${GITHUB_WORKSPACE}/gatsby-config.js`);
38
-
39
- try {
40
- core.setOutput('path_prefix', pathPrefix);
41
- core.notice(`path_prefix in now set to: ${pathPrefix}`);
42
- } catch (err) {
43
- if (!pathPrefix) {
44
- core.setFailed('Missing path prefix');
45
- } else if (pathPrefix === '/') {
46
- core.setFailed('Path prefix "/" is not allowed');
47
- } else if (!pathPrefix.startsWith('/') || !pathPrefix.endsWith('/')) {
48
- core.setFailed('Path prefix should start and end with "/"');
49
- }
50
- }
37
+ const script = require('./.github/scripts/get-path-prefix.js');
38
+ script({ core });
51
39
result-encoding : string
52
- - name : Extract branch name
40
+ - name : Get branch name
53
41
shell : bash
54
- run : echo "##[set-output name=branch;]( ${GITHUB_REF#refs/heads/}) "
55
- id : extract_branch
42
+ run : echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
43
+ id : get_branch
56
44
57
45
echo-state :
58
46
needs : [set-state]
63
51
- run : echo "Clean cache - ${{ needs.set-state.outputs.clean_cache }}"
64
52
- run : echo "Repository org - ${{ github.event.repository.owner.login }}"
65
53
- run : echo "Repository name - ${{ github.event.repository.name }}"
66
- - run : echo "Repository branch - ${{
67
- needs.set-state.outputs.branch_short_ref}}"
54
+ - run : echo "Repository branch - ${{ needs.set-state.outputs.branch_short_ref }}"
68
55
- run : echo "Path prefix - ${{ needs.set-state.outputs.path_prefix }}"
69
- - run : echo "Exclude subfolder - ${{
70
- needs.set-state.outputs.exclude_subfolder }}"
56
+ - run : echo "Exclude subfolder - ${{ needs.set-state.outputs.exclude_subfolder }}"
71
57
72
58
pre-build-dev :
73
59
needs : [set-state]
77
63
- name : check dev azure connection string
78
64
if : env.AIO_AZURE_DEV_CONNECTION_STRING == null
79
65
run : |
80
- echo "::error::Please set the Azure Blob Storage connection string
81
- as AIO_AZURE_DEV_CONNECTION_STRING in Github Secrets"
82
-
66
+ echo "::error::Please set the Azure Blob Storage connection string as AIO_AZURE_DEV_CONNECTION_STRING in Github Secrets"
83
67
exit 1
84
68
env :
85
69
AIO_AZURE_DEV_CONNECTION_STRING : ${{ secrets.AIO_AZURE_DEV_CONNECTION_STRING }}
@@ -97,18 +81,18 @@ jobs:
97
81
- name : Setup Node v16 for Yarn v3
98
82
uses : actions/setup-node@v3
99
83
with :
100
- node-version : " 16.15.0" # Current LTS version
84
+ node-version : ' 16.15.0' # Current LTS version
101
85
102
86
- name : Enable Corepack for Yarn v3
103
87
run : corepack enable
104
88
105
89
- name : Install Yarn v3
106
- uses : borales/actions-yarn@v3.0.0
90
+ uses : borales/actions-yarn@v3
107
91
with :
108
92
cmd : set version stable
109
93
110
94
- name : Install Dependencies
111
- uses : borales/actions-yarn@v3.0.0
95
+ uses : borales/actions-yarn@v3
112
96
env :
113
97
YARN_ENABLE_IMMUTABLE_INSTALLS : false
114
98
with :
@@ -120,25 +104,26 @@ jobs:
120
104
path : |
121
105
public
122
106
.cache
123
- key : ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{
124
- github.run_id }}
107
+ key : ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{ github.run_id }}
125
108
restore-keys : |
126
109
${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-
127
110
128
111
- name : Clean Cache
129
112
if : needs.set-state.outputs.clean_cache == 'true'
130
- uses : borales/actions-yarn@v3.0.0
113
+ uses : borales/actions-yarn@v3
131
114
with :
132
115
cmd : clean
133
116
134
117
- name : Build site
135
-
118
+ uses : borales/actions-yarn@v3
119
+ with :
120
+ cmd : build
136
121
env :
137
- PREFIX_PATHS : true # works like --prefix-paths flag for 'gatsby build'
122
+ PREFIX_PATHS : true # equivalent to --prefix-paths flag for 'gatsby build'
138
123
PATH_PREFIX : ${{ needs.set-state.outputs.path_prefix }}
139
124
GATSBY_ADOBE_LAUNCH_SRC : ${{ secrets.AIO_ADOBE_LAUNCH_DEV_SRC }}
140
125
GATSBY_ADDITIONAL_ADOBE_ANALYTICS_ACCOUNTS : ${{ secrets.AIO_REPORT_SUITE_DEV}}
141
- GATSBY_ADOBE_ANALYTICS_ENV : " dev"
126
+ GATSBY_ADOBE_ANALYTICS_ENV : ' dev'
142
127
REPO_GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
143
128
REPO_OWNER : ${{ github.event.repository.owner.login }}
144
129
REPO_NAME : ${{ github.event.repository.name }}
@@ -156,17 +141,15 @@ jobs:
156
141
GATSBY_ALGOLIA_INDEX_ALL_SRC : ${{ secrets.AIO_ALGOLIA_INDEX_ALL_SRC }}
157
142
GATSBY_ALGOLIA_SEARCH_INDEX : ${{ secrets.AIO_ALGOLIA_SEARCH_INDEX }}
158
143
GATSBY_FEDS_PRIVACY_ID : ${{ secrets.AIO_FEDS_PRIVACY_ID }}
159
- with :
160
- cmd : build
161
144
162
145
- name : Deploy
163
146
uses : icaraps/static-website-deploy@master
164
147
with :
165
- enabled-static-website : " true"
166
- source : " public"
148
+ enabled-static-website : ' true'
149
+ source : ' public'
167
150
target : ${{ needs.set-state.outputs.path_prefix }}
168
151
connection-string : ${{ secrets.AIO_AZURE_DEV_CONNECTION_STRING }}
169
- remove-existing-files : " true"
152
+ remove-existing-files : ' true'
170
153
exclude-subfolder : ${{ needs.set-state.outputs.exclude_subfolder }}
171
154
- name : Delay purge
172
155
run : sleep 60s
@@ -175,8 +158,7 @@ jobs:
175
158
uses : icaraps/gatsby-fastly-purge-action@master
176
159
with :
177
160
fastly-token : ${{ secrets.AIO_FASTLY_TOKEN }}
178
- fastly-url : " ${{ secrets.AIO_FASTLY_DEV_URL}}${{
179
- needs.set-state.outputs.path_prefix }}"
161
+ fastly-url : ' ${{ secrets.AIO_FASTLY_DEV_URL}}${{ needs.set-state.outputs.path_prefix }}'
180
162
181
163
pre-build-production :
182
164
needs : [set-state]
@@ -186,8 +168,7 @@ jobs:
186
168
- name : check prod azure connection string
187
169
if : env.AIO_AZURE_PROD_CONNECTION_STRING == null
188
170
run : |
189
- echo "::error::Please set the Azure Blob Storage connection string
190
- as AIO_AZURE_PROD_CONNECTION_STRING in Github Secrets"
171
+ echo "::error::Please set the Azure Blob Storage connection string as AIO_AZURE_PROD_CONNECTION_STRING in Github Secrets"
191
172
exit 1
192
173
env :
193
174
AIO_AZURE_PROD_CONNECTION_STRING : ${{ secrets.AIO_AZURE_PROD_CONNECTION_STRING }}
@@ -205,18 +186,18 @@ jobs:
205
186
- name : Setup Node v16 for Yarn v3
206
187
uses : actions/setup-node@v3
207
188
with :
208
- node-version : " 16.15.0" # Current LTS version
189
+ node-version : ' 16.15.0' # Current LTS version
209
190
210
191
- name : Enable Corepack for Yarn v3
211
192
run : corepack enable
212
193
213
194
- name : Install Yarn v3
214
- uses : borales/actions-yarn@v3.0.0
195
+ uses : borales/actions-yarn@v3
215
196
with :
216
197
cmd : set version stable
217
198
218
199
- name : Install Dependencies
219
- uses : borales/actions-yarn@v3.0.0
200
+ uses : borales/actions-yarn@v3
220
201
env :
221
202
YARN_ENABLE_IMMUTABLE_INSTALLS : false
222
203
with :
@@ -228,27 +209,26 @@ jobs:
228
209
path : |
229
210
public
230
211
.cache
231
- key : ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{
232
- github.run_id }}
212
+ key : ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{ github.run_id }}
233
213
restore-keys : |
234
214
${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-
235
215
236
216
- name : Clean Cache
237
217
if : needs.set-state.outputs.clean_cache == 'true'
238
- uses : borales/actions-yarn@v3.0.0
218
+ uses : borales/actions-yarn@v3
239
219
with :
240
220
cmd : clean
241
221
242
222
- name : Build site
243
- uses : borales/actions-yarn@v3.0.0
223
+ uses : borales/actions-yarn@v3
244
224
with :
245
225
cmd : build
246
226
env :
247
- PREFIX_PATHS : true # works like --prefix-paths flag for 'gatsby build'
227
+ PREFIX_PATHS : true # equivalent to --prefix-paths flag for 'gatsby build'
248
228
PATH_PREFIX : ${{ needs.set-state.outputs.path_prefix }}
249
229
GATSBY_ADOBE_LAUNCH_SRC : ${{ secrets.AIO_ADOBE_LAUNCH_PROD_SRC }}
250
230
GATSBY_ADDITIONAL_ADOBE_ANALYTICS_ACCOUNTS : ${{ secrets.AIO_REPORT_SUITE_PROD }}
251
- GATSBY_ADOBE_ANALYTICS_ENV : " production"
231
+ GATSBY_ADOBE_ANALYTICS_ENV : ' production'
252
232
REPO_GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
253
233
REPO_OWNER : ${{ github.event.repository.owner.login }}
254
234
REPO_NAME : ${{ github.event.repository.name }}
@@ -272,11 +252,11 @@ jobs:
272
252
- name : Deploy
273
253
uses : icaraps/static-website-deploy@master
274
254
with :
275
- enabled-static-website : " true"
276
- source : " public"
255
+ enabled-static-website : ' true'
256
+ source : ' public'
277
257
target : ${{ needs.set-state.outputs.path_prefix }}
278
258
connection-string : ${{ secrets.AIO_AZURE_PROD_CONNECTION_STRING }}
279
- remove-existing-files : " true"
259
+ remove-existing-files : ' true'
280
260
exclude-subfolder : ${{ needs.set-state.outputs.exclude_subfolder }}
281
261
- name : Delay purge
282
262
run : sleep 60s
@@ -285,5 +265,4 @@ jobs:
285
265
uses : icaraps/gatsby-fastly-purge-action@master
286
266
with :
287
267
fastly-token : ${{ secrets.AIO_FASTLY_TOKEN }}
288
- fastly-url : " ${{ secrets.AIO_FASTLY_PROD_URL }}${{
289
- needs.set-state.outputs.path_prefix }}"
268
+ fastly-url : ' ${{ secrets.AIO_FASTLY_PROD_URL }}${{ needs.set-state.outputs.path_prefix }}'
0 commit comments