-
Notifications
You must be signed in to change notification settings - Fork 2
725 lines (660 loc) · 28.8 KB
/
release.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
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Existing Version to release (*Blank to create a new one)'
required: false
environment:
description: 'The target environment for deployment'
type: environment
required: true
modules:
description: 'Modules you want to deploy (*Names separated by comma, *Blank to deploy every modules)'
required: false
permissions:
contents: write
env:
BOT_USER: Actions Bot
BOT_MAIL: <>
jobs:
CheckInputModules:
name: Check Input Modules
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
outputs:
fe-piattaforma: ${{ steps.modules.outputs.fe-piattaforma }}
ms-ente: ${{ steps.modules.outputs.ms-ente }}
ms-gestione-utente: ${{ steps.modules.outputs.ms-gestione-utente }}
ms-notifiche-integration: ${{ steps.modules.outputs.ms-notifiche-integration }}
ms-open-data: ${{ steps.modules.outputs.ms-open-data }}
ms-programma-progetto: ${{ steps.modules.outputs.ms-programma-progetto }}
ms-questionario-cittadino: ${{ steps.modules.outputs.ms-questionario-cittadino }}
steps:
- uses: actions/checkout@v3
with:
# this allow the workflow to be rerun after changes have been pushed from previous jobs
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set modules required
id: modules
run: |
environment="${{ github.event.inputs.environment }}"
in="${{ github.event.inputs.modules }}"
in=${in// /}
if [[ "$in" != "" ]] && [[ "$environment" == "Development" ]]; then
echo "fe-piattaforma=false" >> $GITHUB_OUTPUT
echo "ms-ente=false" >> $GITHUB_OUTPUT
echo "ms-gestione-utente=false" >> $GITHUB_OUTPUT
echo "ms-notifiche-integration=false" >> $GITHUB_OUTPUT
echo "ms-open-data=false" >> $GITHUB_OUTPUT
echo "ms-programma-progetto=false" >> $GITHUB_OUTPUT
echo "ms-questionario-cittadino=false" >> $GITHUB_OUTPUT
arrIN=(${in//,/ })
for i in "${arrIN[@]}"; do
case $i in
fe-piattaforma)
echo "fe-piattaforma=true" >> $GITHUB_OUTPUT
;;
ms-ente)
echo "ms-ente=true" >> $GITHUB_OUTPUT
;;
ms-gestione-utente)
echo "ms-gestione-utente=true" >> $GITHUB_OUTPUT
;;
ms-notifiche-integration)
echo "ms-notifiche-integration=true" >> $GITHUB_OUTPUT
;;
ms-open-data)
echo "ms-open-data=true" >> $GITHUB_OUTPUT
;;
ms-programma-progetto)
echo "ms-programma-progetto=true" >> $GITHUB_OUTPUT
;;
ms-questionario-cittadino)
echo "ms-questionario-cittadino=true" >> $GITHUB_OUTPUT
;;
*)
echo "Unknown $i"
exit 1
;;
esac
done
else
echo "fe-piattaforma=true" >> $GITHUB_OUTPUT
echo "ms-ente=true" >> $GITHUB_OUTPUT
echo "ms-gestione-utente=true" >> $GITHUB_OUTPUT
echo "ms-notifiche-integration=true" >> $GITHUB_OUTPUT
echo "ms-open-data=true" >> $GITHUB_OUTPUT
echo "ms-programma-progetto=true" >> $GITHUB_OUTPUT
echo "ms-questionario-cittadino=true" >> $GITHUB_OUTPUT
fi
DryRunRelease:
needs: CheckInputModules
name: Dry-Run Release
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
outputs:
version: ${{ steps.version.outputs.VERSION }}
steps:
- uses: actions/checkout@v3
with:
# this allow the workflow to be rerun after changes have been pushed from previous jobs
ref: ${{ github.ref }}
fetch-depth: 0
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Install semantic-release extra plugins
run: |
npm install --save-dev \
@semantic-release/commit-analyzer \
@semantic-release/changelog \
@semantic-release/git \
@semantic-release/release-notes-generator \
@semantic-release/exec \
- name: Create .VERSION file
run: echo "There are no relevant changes, so no new version is released" > .VERSION
- name: Dry-Run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release --dry-run --no-ci
- name: Version
id: version
run: |
nextversion=$(cat .VERSION)
echo "VERSION=$nextversion" >> $GITHUB_OUTPUT
echo "Next version: $nextversion"
- name: Check changes
if: ${{ github.event.inputs.version == '' }}
run: |
nextversion=$(cat .VERSION)
regex="^(([0-9]+).([0-9]+).([0-9]+)(-[A-Za-z]*.[0-9]*)?)$"
if [[ $nextversion =~ $regex ]]; then
echo "===> Changes detected: Release started!"
else
echo "===> No changes detected: Release stopped!"
echo "### No relevant changes detected: no new version is released!" >> $GITHUB_STEP_SUMMARY
exit 1
fi
buildFE:
if: ${{ github.event.inputs.version == '' && needs.CheckInputModules.outputs.fe-piattaforma == 'true' }}
needs: [CheckInputModules, DryRunRelease]
name: FE Build
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
defaults:
run:
shell: bash
working-directory: ${{ github.workspace }}/fe-piattaforma
steps:
- uses: actions/[email protected]
with:
# this allow the workflow to be rerun after changes have been pushed from previous jobs
ref: ${{ github.ref }}
lfs: 'true'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Modify Env File
run: |
sed -i "s/{{_REACT_APP_BE_BASE_URL_}}/${{ secrets.REACT_APP_BE_BASE_URL }}/g" .env
sed -i "s/{{_REACT_APP_COGNITO_BASE_URL_}}/${{ secrets.REACT_APP_COGNITO_BASE_URL }}/g" .env
sed -i "s/{{_REACT_APP_COGNITO_CLIENT_ID_}}/${{ secrets.REACT_APP_COGNITO_CLIENT_ID }}/g" .env
sed -i "s/{{_REACT_APP_COGNITO_CLIENT_SECRET_}}/${{ secrets.REACT_APP_COGNITO_CLIENT_SECRET }}/g" .env
sed -i "s/{{_REACT_APP_COGNITO_FE_REDIRECT_URL_}}/${{ secrets.REACT_APP_COGNITO_FE_REDIRECT_URL }}/g" .env
sed -i "s/{{_REACT_APP_DASHBOARD_BASE_URL_}}/${{ secrets.REACT_APP_DASHBOARD_BASE_URL }}/g" .env
sed -i "s/{{_REACT_APP_DASHBOARD_BI_URL_}}/${{ secrets.REACT_APP_DASHBOARD_BI_URL }}/g" .env
sed -i "s/{{_REACT_APP_DRUPAL_BASE_URL_}}/${{ secrets.REACT_APP_DRUPAL_BASE_URL }}/g" .env
sed -i "s/{{_REACT_APP_DRUPAL_SETTINGS_}}/${{ secrets.REACT_APP_DRUPAL_SETTINGS }}/g" .env
sed -i "s/{{_REACT_APP_ROCKET_CHAT_BASE_URL_}}/${{ secrets.REACT_APP_ROCKET_CHAT_BASE_URL }}/g" .env
sed -i "s/{{_REACT_APP_ROCKET_CHAT_SETTINGS_}}/${{ secrets.REACT_APP_ROCKET_CHAT_SETTINGS }}/g" .env
sed -i "s/{{_REACT_APP_WORKDOCS_BASE_URL_}}/${{ secrets.REACT_APP_WORKDOCS_BASE_URL }}/g" .env
sed -i "s/{{_REACT_APP_WORKDOCS_SETTINGS_}}/${{ secrets.REACT_APP_WORKDOCS_SETTINGS }}/g" .env
sed -i "s/{{_REACT_APP_QUICKSIGHT_BASE_URL_}}/${{ secrets.REACT_APP_QUICKSIGHT_BASE_URL }}/g" .env
sed -i "s/{{_REACT_APP_QUICKSIGHT_SETTINGS_}}/${{ secrets.REACT_APP_QUICKSIGHT_SETTINGS }}/g" .env
- name: File Regex Replace
uses: mingjun97/file-regex-replace@v1
with:
# regex to apply(regex)
regex: '"version":[\s\S]"[0-9].[0-9].[0-9]"'
# flags of the regex
flags: "gmi"
# replacement string
replacement: '"version": "${{needs.DryRunRelease.outputs.version}}"'
# Files to be replaced(regex)
include: "package.json"
- name: Install FE dependencies
run: |
npm install --force
- name: Build & Push Image to Amazon ECR
id: build
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: fe-piattaforma
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}}
run: |
npm run build
docker build . \
--target builder \
--file Dockerfile \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
buildBE:
if: ${{ github.event.inputs.version == '' && (needs.CheckInputModules.outputs.ms-ente == 'true' ||
needs.CheckInputModules.outputs.ms-gestione-utente == 'true' || needs.CheckInputModules.outputs.ms-notifiche-integration == 'true' ||
needs.CheckInputModules.outputs.ms-open-data == 'true' || needs.CheckInputModules.outputs.ms-programma-progetto == 'true' ||
needs.CheckInputModules.outputs.ms-questionario-cittadino == 'true' ) }}
needs: [CheckInputModules, DryRunRelease]
name: BE Build
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- uses: actions/[email protected]
with:
# this allow the workflow to be rerun after changes have been pushed from previous jobs
ref: ${{ github.ref }}
lfs: 'true'
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt-openj9'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Install Lib repdgt-shared
if: ${{ success() }}
run: |
cd ${{ github.workspace }}/lib-repdgt-shared
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
mvn install
- name: ms-ente Build & Push Image to Amazon ECR
id: ms-ente
if: ${{ success() && needs.CheckInputModules.outputs.ms-ente == 'true' }}
working-directory: ${{ github.workspace }}/ms-ente
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-ente
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}}
run: |
# set version
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
# build
mvn package
echo "======DOCKERFILE======"
cat Dockerfile
echo "====================="
# docker build
docker build . \
--file Dockerfile \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# docker push
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: ms-gestione-utente Build & Push Image to Amazon ECR
id: ms-gestione-utente
if: ${{ success() && needs.CheckInputModules.outputs.ms-gestione-utente == 'true' }}
working-directory: ${{ github.workspace }}/ms-gestione-utente
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-gestione-utente
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}}
run: |
# set version
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
# build
mvn package
echo "======DOCKERFILE======"
cat Dockerfile
echo "====================="
# docker build
docker build . \
--file Dockerfile \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# docker push
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: ms-notifiche-integration Build & Push Image to Amazon ECR
id: ms-notifiche-integration
if: ${{ success() && needs.CheckInputModules.outputs.ms-notifiche-integration == 'true' }}
working-directory: ${{ github.workspace }}/ms-notifiche-integration
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-notifiche-integration
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}}
run: |
# set version
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
# build
mvn package
echo "======DOCKERFILE======"
cat Dockerfile
echo "====================="
# docker build
docker build . \
--file Dockerfile \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# docker push
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: ms-open-data Build & Push Image to Amazon ECR
id: ms-open-data
if: ${{ success() && needs.CheckInputModules.outputs.ms-open-data == 'true' }}
working-directory: ${{ github.workspace }}/ms-open-data
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-open-data
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}}
run: |
# set version
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
# build
mvn package
echo "======DOCKERFILE======"
cat Dockerfile
echo "====================="
# docker build
docker build . \
--file Dockerfile \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# docker push
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: ms-programma-progetto Build & Push Image to Amazon ECR
id: ms-programma-progetto
if: ${{ success() && needs.CheckInputModules.outputs.ms-programma-progetto == 'true' }}
working-directory: ${{ github.workspace }}/ms-programma-progetto
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-programma-progetto
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}}
run: |
# set version
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
# build
mvn package
echo "======DOCKERFILE======"
cat Dockerfile
echo "====================="
# docker build
docker build . \
--file Dockerfile \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# docker push
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: ms-questionario-cittadino Build & Push Image to Amazon ECR
id: ms-questionario-cittadino
if: ${{ success() && needs.CheckInputModules.outputs.ms-questionario-cittadino == 'true' }}
working-directory: ${{ github.workspace }}/ms-questionario-cittadino
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-questionario-cittadino
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}}
run: |
# set version
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
# build
mvn package
echo "======DOCKERFILE======"
cat Dockerfile
echo "====================="
# docker build
docker build . \
--file Dockerfile \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# docker push
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
Deploy:
needs: [CheckInputModules, DryRunRelease, buildFE, buildBE]
if: ${{ always() &&
needs.DryRunRelease.result == 'success' &&
(needs.buildFE.result == 'success' || needs.buildFE.result == 'skipped') &&
(needs.buildBE.result == 'success' || needs.buildBE.result == 'skipped') }}
name: Deploy
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
defaults:
run:
shell: bash
outputs:
IMAGETAG: ${{ steps.imagetag.outputs.IMAGETAG }}
steps:
- uses: actions/[email protected]
with:
# this allow the workflow to be rerun after changes have been pushed from previous jobs
ref: ${{ github.ref }}
fetch-depth: '0'
- name: Check Input Version
if: ${{ github.event.inputs.version != '' }}
id: checkver
run: |
version="${{ github.event.inputs.version }}"
echo "==> Version: $version"
if [ $(git tag -l "$version" | wc -l) -gt 0 ]; then
echo "Version $version exists. Input accepted."
else
echo "Version $version doesn't exist. INVALID INPUT."
exit 1
fi
- uses: azure/[email protected]
with:
version: 'v1.23.6' # default is latest stable
id: install
- name: Configure AWS credentials for ECR
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Configure AWS credentials for K8S
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: Git
role-duration-seconds: 3600
- name: Setup Kubeconfig
run: |
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ secrets.AWS_CLUSTER }}
- name: Setup Image TAG
id: imagetag
run: |
if [ "${{ github.event.inputs.version }}" = "" ]; then
echo "IMAGETAG=$(echo ${{needs.DryRunRelease.outputs.version}} )" >> $GITHUB_OUTPUT
else
echo "IMAGETAG=$(echo ${{ github.event.inputs.version }} )" >> $GITHUB_OUTPUT
fi
- name: Setup 'fe-piattaforma' deployment.tmp.yaml
if: ${{ success() && needs.CheckInputModules.outputs.fe-piattaforma == 'true' }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: fe-piattaforma
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }}
run: |
cd ${{ github.workspace }}/fe-piattaforma/k8s
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY
export IMAGE_TAG=$IMAGE_TAG
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }}
export K8S_INGRESS_CERTIFICATE=${{ secrets.K8S_INGRESS_CERTIFICATE }}
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml
- name: Setup 'ms-ente' deployment.tmp.yaml
if: ${{ success() && needs.CheckInputModules.outputs.ms-ente == 'true' }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-ente
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }}
run: |
cd ${{ github.workspace }}/ms-ente/k8s
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY
export IMAGE_TAG=$IMAGE_TAG
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }}
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml
- name: Setup 'ms-gestione-utente' deployment.tmp.yaml
if: ${{ success() && needs.CheckInputModules.outputs.ms-gestione-utente == 'true' }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-gestione-utente
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }}
run: |
cd ${{ github.workspace }}/ms-gestione-utente/k8s
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY
export IMAGE_TAG=$IMAGE_TAG
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }}
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml
- name: Setup 'ms-notifiche-integration' deployment.tmp.yaml
if: ${{ success() && needs.CheckInputModules.outputs.ms-notifiche-integration == 'true' }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-notifiche-integration
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }}
run: |
cd ${{ github.workspace }}/ms-notifiche-integration/k8s
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY
export IMAGE_TAG=$IMAGE_TAG
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }}
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml
- name: Setup 'ms-open-data' deployment.tmp.yaml
if: ${{ success() && needs.CheckInputModules.outputs.ms-open-data == 'true' }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-open-data
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }}
run: |
cd ${{ github.workspace }}/ms-open-data/k8s
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY
export IMAGE_TAG=$IMAGE_TAG
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }}
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml
- name: Setup 'ms-programma-progetto' deployment.tmp.yaml
if: ${{ success() && needs.CheckInputModules.outputs.ms-programma-progetto == 'true' }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-programma-progetto
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }}
run: |
cd ${{ github.workspace }}/ms-programma-progetto/k8s
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY
export IMAGE_TAG=$IMAGE_TAG
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }}
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml
- name: Setup 'ms-questionario-cittadino' deployment.tmp.yaml
if: ${{ success() && needs.CheckInputModules.outputs.ms-questionario-cittadino == 'true' }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ms-questionario-cittadino
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }}
run: |
cd ${{ github.workspace }}/ms-questionario-cittadino/k8s
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY
export IMAGE_TAG=$IMAGE_TAG
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }}
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml
- name: Deploy
run: |
cd ${{ github.workspace }}
echo "===DEPLOYMENT FILE==="
cat deployment.yml
echo "====================="
kubectl apply -f deployment.yml
RepoUpdate:
needs: [CheckInputModules, DryRunRelease, Deploy]
if: ${{ github.event.inputs.version == '' && always() &&
needs.CheckInputModules.result == 'success' && needs.DryRunRelease.result == 'success' && needs.Deploy.result == 'success' &&
(needs.buildFE.result == 'success' || needs.buildFE.result == 'skipped') &&
(needs.buildBE.result == 'success' || needs.buildBE.result == 'skipped') }}
name: Repo Update
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
defaults:
run:
shell: bash
working-directory: ${{ github.workspace }}/fe-piattaforma
steps:
- uses: actions/[email protected]
with:
token: ${{ secrets.PAT_REPDIGITALE_AUTOMATION }}
# this allow the workflow to be rerun after changes have been pushed from previous jobs
ref: ${{ github.ref }}
persist-credentials: 'true'
fetch-depth: '0'
- name: File Package Update
if: ${{ needs.CheckInputModules.outputs.fe-piattaforma == 'true' }}
uses: mingjun97/file-regex-replace@v1
with:
# regex to apply(regex)
regex: '"version":[\s\S]"[0-9].[0-9].[0-9]"'
# flags of the regex
flags: "gmi"
# replacement string
replacement: '"version": "${{needs.DryRunRelease.outputs.version}}"'
# Files to be replaced(regex)
include: "package.json"
- name: File POM Update
if: ${{ success() }}
run: |
cd ${{ github.workspace }}/lib-repdgt-shared
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
in="${{ needs.CheckInputModules.outputs.ms-ente }}"
if [ "$in" == "true" ]; then
cd ${{ github.workspace }}/ms-ente
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
fi
in="${{ needs.CheckInputModules.outputs.ms-gestione-utente }}"
if [ "$in" == "true" ]; then
cd ${{ github.workspace }}/ms-gestione-utente
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
fi
in="${{ needs.CheckInputModules.outputs.ms-notifiche-integration }}"
if [ "$in" == "true" ]; then
cd ${{ github.workspace }}/ms-notifiche-integration
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
fi
in="${{ needs.CheckInputModules.outputs.ms-open-data }}"
if [ "$in" == "true" ]; then
cd ${{ github.workspace }}/ms-open-data
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
fi
in="${{ needs.CheckInputModules.outputs.ms-programma-progetto }}"
if [ "$in" == "true" ]; then
cd ${{ github.workspace }}/ms-programma-progetto
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
fi
in="${{ needs.CheckInputModules.outputs.ms-questionario-cittadino }}"
if [ "$in" == "true" ]; then
cd ${{ github.workspace }}/ms-questionario-cittadino
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}}
fi
- name: Push files updated
run: |
cd ${{ github.workspace }}
git diff
git config user.email "$BOT_MAIL"
git config user.name "$BOT_USER"
git add -A
git commit -m "chore: update version ${{needs.DryRunRelease.outputs.version}}" || exit 0
git push
Release:
needs: [RepoUpdate]
if: ${{ github.event.inputs.version == '' && always() && needs.RepoUpdate.result == 'success' }}
name: Release
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- uses: actions/[email protected]
with:
# this allow the workflow to be rerun after changes have been pushed from previous jobs
ref: ${{ github.ref }}
token: ${{ secrets.PAT_REPDIGITALE_AUTOMATION }}
persist-credentials: 'true'
fetch-depth: '0'
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Install semantic-release extra plugins
run: |
npm install --save-dev \
@semantic-release/commit-analyzer \
@semantic-release/changelog \
@semantic-release/git \
@semantic-release/release-notes-generator \
@semantic-release/exec \
- name: Create .VERSION file
run: echo "There are no relevant changes, so no new version is released" > .VERSION
- name: Release
env:
# ad-hoc token (PAT) in order to permit the push on a protected branch
# without protected branches can be use secrets.GITHUB_TOKEN
GITHUB_TOKEN: ${{ secrets.PAT_REPDIGITALE_AUTOMATION }}
run: |
npx semantic-release
- name: Version
id: version
run: |
nextversion=$(cat .VERSION)
echo "VERSION=$nextversion" >> $GITHUB_OUTPUT
echo "### Release $nextversion created!" >> $GITHUB_STEP_SUMMARY