This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
497 lines (488 loc) · 17.5 KB
/
deploy-preview-storefrontcloud.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
name: Deploy PR Preview on Storefrontcloud
env:
PWA_HOST: https://shopware-pwa-canary.storefrontcloud.io
INSTANCE_CODE: shopware-pwa-test-europe-west1-gcp-storefrontcloud-io
EXPERIMENTAL_IMAGE_PROCESSING_SERVER: https://test-shopware-pwa-images.vercel.app/api/image
on:
pull_request:
types: [opened, synchronize]
paths-ignore:
- "*.md"
- ".github/**"
- "docs/**"
jobs:
init:
name: Init dependencies
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Cache node_modules
uses: actions/cache@v2
id: step-cache-node-modules
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
if: steps.step-cache-node-modules.outputs.cache-hit != 'true'
run: |
yarn --frozen-lockfile
build-cli:
name: Build CLI
needs: init
runs-on: ubuntu-latest
outputs:
package-hash: ${{ steps.folder-hash-step-cli.outputs.hash }}
strategy:
matrix:
node: [14, 16]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Check hash for directory packages/cli
id: folder-hash-step-cli
run: |
HASH=$(git rev-parse HEAD:packages/cli)
echo "::set-output name=hash::$HASH"
echo "Hash is: $HASH"
- name: Cache cli build
id: step-cache-build
uses: actions/cache@v2
env:
cache-name: test-cache-cli-build
with:
path: |
packages/cli/build
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ steps.folder-hash-step-cli.outputs.hash }}
- name: Cache node_modules
if: steps.step-cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Build CLI
if: steps.step-cache-build.outputs.cache-hit != 'true'
run: |
cd ./packages/cli/
yarn build
build-composables:
name: Build composables package
needs: init
runs-on: ubuntu-latest
outputs:
package-hash: ${{ steps.folder-hash-step-composables.outputs.hash }}
strategy:
matrix:
node: [14, 16]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Check hash for directory packages/composables
id: folder-hash-step-composables
run: |
HASH=$(git rev-parse HEAD:packages/composables)
echo "::set-output name=hash::$HASH"
echo "Hash is: $HASH"
- name: Cache composables build
id: step-cache-build
uses: actions/cache@v2
env:
cache-name: test-cache-composables-build
with:
path: |
packages/composables/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ steps.folder-hash-step-composables.outputs.hash }}
- name: Cache node_modules
if: steps.step-cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Build Composables
if: steps.step-cache-build.outputs.cache-hit != 'true'
run: |
yarn build composables --ci
build-helpers:
name: Build helpers package
needs: init
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
outputs:
package-hash: ${{ steps.folder-hash-step-helpers.outputs.hash }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Check hash for directory packages/helpers
id: folder-hash-step-helpers
run: |
HASH=$(git rev-parse HEAD:packages/helpers)
echo "::set-output name=hash::$HASH"
echo "Hash is: $HASH"
- name: Cache helpers build
id: step-cache-build
uses: actions/cache@v2
env:
cache-name: test-cache-helpers-build
with:
path: |
packages/helpers/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ steps.folder-hash-step-helpers.outputs.hash }}
- name: Cache node_modules
if: steps.step-cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Build helpers
if: steps.step-cache-build.outputs.cache-hit != 'true'
run: |
yarn build helpers --ci
build-nuxt-module:
name: Build nuxt-module package
needs: init
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
outputs:
package-hash: ${{ steps.folder-hash-step-nuxt-module.outputs.hash }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Check hash for directory packages/nuxt-module
id: folder-hash-step-nuxt-module
run: |
HASH=$(git rev-parse HEAD:packages/nuxt-module)
echo "::set-output name=hash::$HASH"
echo "Hash is: $HASH"
- name: Cache nuxt-module build
id: step-cache-build
uses: actions/cache@v2
env:
cache-name: test-cache-nuxt-module-build
with:
path: |
packages/nuxt-module/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ steps.folder-hash-step-nuxt-module.outputs.hash }}
- name: Cache node_modules
if: steps.step-cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Build nuxt-module
if: steps.step-cache-build.outputs.cache-hit != 'true'
run: |
yarn build nuxt-module --ci
build-shopware-6-client:
name: Build shopware-6-client package
needs: init
runs-on: ubuntu-latest
outputs:
package-hash: ${{ steps.folder-hash-step-shopware-6-client.outputs.hash }}
strategy:
matrix:
node: [14, 16]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Check hash for directory packages/shopware-6-client
id: folder-hash-step-shopware-6-client
run: |
HASH=$(git rev-parse HEAD:packages/shopware-6-client)
echo "::set-output name=hash::$HASH"
echo "Hash is: $HASH"
- name: Cache shopware-6-client build
id: step-cache-build
uses: actions/cache@v2
env:
cache-name: test-cache-shopware-6-client-build
with:
path: |
packages/shopware-6-client/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ steps.folder-hash-step-shopware-6-client.outputs.hash }}
- name: Cache node_modules
if: steps.step-cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Build shopware-6-client
if: steps.step-cache-build.outputs.cache-hit != 'true'
run: |
yarn build shopware-6-client --ci
build-default-theme:
name: Build default-theme package
needs: init
runs-on: ubuntu-latest
outputs:
package-hash: ${{ steps.folder-hash-step-default-theme.outputs.hash }}
strategy:
matrix:
node: [14, 16]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Check hash for directory packages/default-theme
id: folder-hash-step-default-theme
run: |
HASH=$(git rev-parse HEAD:packages/default-theme)
echo "::set-output name=hash::$HASH"
echo "Hash is: $HASH"
- name: Cache default-theme build
id: step-cache-build
uses: actions/cache@v2
env:
cache-name: test-cache-default-theme-build
with:
path: |
packages/default-theme/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ steps.folder-hash-step-default-theme.outputs.hash }}
- name: Cache node_modules
if: steps.step-cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Build default-theme
if: steps.step-cache-build.outputs.cache-hit != 'true'
run: |
node scripts/linkDependencies.js && yarn lerna link
yarn build default-theme --ci
create-test-project:
name: Create test project
needs:
[
build-cli,
build-composables,
build-helpers,
build-nuxt-module,
build-shopware-6-client,
build-default-theme,
]
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Cache cli build
uses: actions/cache@v2
env:
cache-name: test-cache-cli-build
with:
path: |
packages/cli/build
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ needs.build-cli.outputs.package-hash }}
- name: Cache composables build
uses: actions/cache@v2
env:
cache-name: test-cache-composables-build
with:
path: |
packages/composables/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ needs.build-composables.outputs.package-hash }}
- name: Cache helpers build
uses: actions/cache@v2
env:
cache-name: test-cache-helpers-build
with:
path: |
packages/helpers/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ needs.build-helpers.outputs.package-hash }}
- name: Cache nuxt-module build
uses: actions/cache@v2
env:
cache-name: test-cache-nuxt-module-build
with:
path: |
packages/nuxt-module/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ needs.build-nuxt-module.outputs.package-hash }}
- name: Cache shopware-6-client build
uses: actions/cache@v2
env:
cache-name: test-cache-shopware-6-client-build
with:
path: |
packages/shopware-6-client/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ needs.build-shopware-6-client.outputs.package-hash }}
- name: Cache default-theme build
uses: actions/cache@v2
env:
cache-name: test-cache-default-theme-build
with:
path: |
packages/default-theme/dist
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ needs.build-default-theme.outputs.package-hash }}
# Step to speed up project init
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Link packages
run: |
node ./scripts/linkDependencies.js
# Step to speed up project init
- name: Cache test-project
uses: actions/cache@v2
env:
cache-name: test-cache-test-project
with:
path: |
test-project
!test-project/.shopware-pwa
!test-project/.yalc
!test-project/.yalc.lock
key: ${{ matrix.node }}-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}-${{ needs.build-cli.outputs.package-hash }}
- name: Create a project
run: |
mkdir -p test-project
cd ./test-project
../packages/cli/bin/shopware-pwa init --username=${{ secrets.SHOPWARE_ADMIN_USER }} --password=${{ secrets.SHOPWARE_ADMIN_PASSWORD }} --shopwareDomainsAllowList=${{ env.PWA_HOST }} --ci --devMode --stage local
- name: Build test project
run: |
yarn
node ./scripts/yalcPushPackages.js
node ./scripts/yalcLinkTestProject.js
cd ./test-project
yarn
yarn build
- name: Login to DockerHub
if: matrix.node == 16
uses: docker/[email protected]
with:
registry: registry.storefrontcloud.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
if: matrix.node == 16
uses: docker/[email protected]
with:
context: ./test-project
push: true
labels: preview
tags: registry.storefrontcloud.io/shopware-pwa-storefrontcloud-io/vue-storefront:${{ github.sha }}
- name: Add information about PR from forked repo
if: github.repository_owner != 'vuestorefront'
uses: mshick/add-pr-comment@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: false
message: |
:warning: This PR comes from forked repository and cannot be deployed on our preview instance!
Nevertheless, thank you, we are going to see it in action locally first 👍
deploy:
runs-on: ubuntu-latest
needs: create-test-project
steps:
- uses: chrnorm/deployment-action@releases/v1
name: Create GitHub deployment
id: deployment
with:
token: "${{ github.token }}"
environment: preview
initial_status: in_progress
- name: Deploy on Storefrontcloud.io
id: deploy
uses: StorefrontCloud/[email protected]
if: github.repository_owner == 'vuestorefront'
with:
token: "${{ github.token }}"
namespace: "${{env.INSTANCE_CODE}}"
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Comment PR
if: success()
uses: StorefrontCloud/storefrontcloud-comment-pr-preview-deploy@master
with:
preview_url: "${{ steps.deploy.outputs.preview_url }}"
token: "${{ github.token }}"
namespace: "${{env.INSTANCE_CODE}}"
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ github.token }}"
target-url: ${{ steps.deploy.outputs.preview_url }}
state: "success"
description: Congratulations! The deploy is done.
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ github.token }}"
description: Unfortunately, the instance hasn't been updated.
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}