generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (176 loc) · 6.94 KB
/
release-deploy.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
name: Release And Deploy
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
environment:
required: true
type: choice
description: Select the Environment
options:
- dev
- uat
- prod
- all
domain:
required: true
type: choice
description: Select the domain
options:
- weu-shared
- itn-printit
semver:
required: true
type: choice
description: Select the new Semantic Version
options:
- major
- minor
- patch
- buildNumber
- skip
default: skip
beta:
required: false
type: boolean
description: deploy beta version on AKS
default: false
permissions:
packages: write
contents: write
issues: write
id-token: write
actions: read
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.get_semver.outputs.semver }}
environment: ${{ steps.output.outputs.environment }}
steps:
- name: Get semver
id: get_semver
uses: pagopa/github-actions-template/semver-setup@0018ad6b766a082c35ec88cd9f18de6b54fd59d1 # v1.4.2
- if: ${{ github.event.inputs.environment == null || github.event.inputs.environment == 'dev' }}
run: echo "ENVIRNOMENT=dev" >> $GITHUB_ENV
- if: ${{ github.event.inputs.environment == 'uat' }}
run: echo "ENVIRNOMENT=uat" >> $GITHUB_ENV
- if: ${{ github.event.inputs.environment == 'prod' }}
run: echo "ENVIRNOMENT=prod" >> $GITHUB_ENV
- if: ${{ github.event.inputs.environment == 'all' }}
run: echo "ENVIRNOMENT=all" >> $GITHUB_ENV
- id: output
name: Set Output
run: |
echo "environment=${{env.ENVIRNOMENT}}" >> $GITHUB_OUTPUT
release:
name: Create a New Release
runs-on: ubuntu-latest
needs: [ setup ]
outputs:
version: ${{ steps.release.outputs.version }}
steps:
- name: Make Release
id: release
uses: pagopa/github-actions-template/maven-release@d63ef91b9b1f0021276f0d63dadf42067d0b49f6 # v1.5.2
with:
semver: ${{ needs.setup.outputs.semver }}
github_token: ${{ secrets.BOT_TOKEN_GITHUB }}
beta: ${{ inputs.beta }}
skip_ci: ${{ inputs.beta }}
# image:
# needs: [ setup, release ]
# name: Build and Push Docker Image
# runs-on: ubuntu-latest
# if: ${{ inputs.semver != 'skip' }}
# steps:
# - name: Build and Push
# id: semver
# uses: pagopa/github-actions-template/[email protected]
# with:
# branch: ${{ github.ref_name}}
# github_token: ${{ secrets.GITHUB_TOKEN }}
# tag: ${{ needs.release.outputs.version }}
deploy_app_service_node:
# needs: [ setup, release, image ]
needs: [ setup, release ]
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
name: Deploy on App Service Node
runs-on: ubuntu-latest
steps:
- if: ${{ github.event.inputs.environment == null || github.event.inputs.environment == 'dev' }}
run: echo "SHORT_ENV=d" >> $GITHUB_ENV
- if: ${{ github.event.inputs.environment == 'uat' }}
run: echo "SHORT_ENV=u" >> $GITHUB_ENV
- if: ${{ github.event.inputs.environment == 'prod' }}
run: echo "SHORT_ENV=p" >> $GITHUB_ENV
- name: Azure Pipelines Action
uses: jacopocarlini/azure-pipelines@b9721743a54e862597395b4a70727cfdc03028fb # v1.3
with:
azure-devops-project-url: https://dev.azure.com/pagopaspa/pagoPA-projects
azure-pipeline-name: 'pagopa-pdf-engine.deploy'
azure-devops-token: ${{ secrets.AZURE_DEVOPS_TOKEN }}
azure-template-parameters: |
{
"ENV": "${{inputs.environment}}",
"SEMVER": "${{inputs.semver}}",
"DOCKERFILE": "node/Dockerfile",
"BUILD_CONTEXT": "./node",
"IMAGE_NAME": "pagopapdfengine",
"TYPE": "node",
"APP_SERVICE_NAME": "pagopa-${{ env.SHORT_ENV }}-${{inputs.domain}}-app-pdf-engine${{ env.SHORT_ENV == 'prod' && '-ha' || '' }}",
"APP_SERVICE_RESOURCE_GROUP": "pagopa-${{ env.SHORT_ENV }}-${{inputs.domain}}-pdf-engine-rg"
}
azure-pipeline-variables: '{"system.debug": "true"}'
deploy_app_service_java:
# needs: [ setup, release, image, deploy_app_service_node ]
needs: [ setup, release, deploy_app_service_node ]
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
name: Deploy on App Service Java
runs-on: ubuntu-latest
steps:
- if: ${{ github.event.inputs.environment == null || github.event.inputs.environment == 'dev' }}
run: echo "SHORT_ENV=d" >> $GITHUB_ENV
- if: ${{ github.event.inputs.environment == 'uat' }}
run: echo "SHORT_ENV=u" >> $GITHUB_ENV
- if: ${{ github.event.inputs.environment == 'prod' }}
run: echo "SHORT_ENV=p" >> $GITHUB_ENV
- name: Azure Pipelines Action
uses: jacopocarlini/azure-pipelines@b9721743a54e862597395b4a70727cfdc03028fb # v1.3
with:
azure-devops-project-url: https://dev.azure.com/pagopaspa/pagoPA-projects
azure-pipeline-name: 'pagopa-pdf-engine.deploy'
azure-devops-token: ${{ secrets.AZURE_DEVOPS_TOKEN }}
azure-template-parameters: |
{
"ENV": "${{inputs.environment}}",
"SEMVER": "${{inputs.semver}}",
"DOCKERFILE": "Dockerfile",
"BUILD_CONTEXT": ".",
"IMAGE_NAME": "pagopapdfenginejava",
"TYPE": "java",
"APP_SERVICE_NAME": "pagopa-${{ env.SHORT_ENV }}-${{inputs.domain}}-app-pdf-engine-java${{ env.SHORT_ENV == 'prod' && '-ha' || '' }}",
"APP_SERVICE_RESOURCE_GROUP": "pagopa-${{ env.SHORT_ENV }}-${{inputs.domain}}-pdf-engine-rg"
}
azure-pipeline-variables: '{"system.debug": "true"}'
notify:
needs: [ deploy_app_service_node, deploy_app_service_java ]
runs-on: ubuntu-latest
name: Notify
if: always()
steps:
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@be814b201e233b2dc673608aa46e5447c8ab13f2 # v2
with:
status: ${{ needs.deploy_aks.result }}
token: ${{ secrets.GITHUB_TOKEN }}
notify_when: 'failure,skipped'
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} <{workflow_url}|{workflow}> {status_message} in <{repo_url}|{repo}>'
footer: 'Linked to Repo <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}