generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 40
243 lines (218 loc) · 8.21 KB
/
release_to_azure.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
name: Release to Azure
on:
push:
branches:
- master
- production
- test
- demo1
- demo2
- demo3
defaults:
run:
working-directory: prime-router
jobs:
pre_job:
name: "Set Build Environment"
runs-on: ubuntu-latest
outputs:
env_name: ${{ steps.build_vars.outputs.env_name }}
version: ${{ steps.build_vars.outputs.version }}
has_router_change: ${{ steps.build_vars.outputs.has_router_change }}
has_frontend_change: ${{ steps.build_vars.outputs.has_frontend_change }}
dns_ip: ${{ steps.build_vars.outputs.dns_ip }}
steps:
- name: Check out changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Build vars
id: build_vars
uses: ./.github/actions/build-vars
with:
sp-creds: ${{ secrets.SERVICE_PRINCIPAL_CREDS }}
build_router_release:
name: "Release: Build Router"
needs:
- pre_job
if: needs.pre_job.outputs.has_router_change == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Build backend
uses: ./.github/actions/build-backend
with:
version: ${{ needs.pre_job.outputs.version }}
build_frontend_react_release:
name: "Release: Build Frontend (React)"
needs:
- pre_job
if: needs.pre_job.outputs.has_frontend_change == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend-react
steps:
- name: Check out changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Build frontend
uses: ./.github/actions/build-frontend
with:
env-name: ${{ needs.pre_job.outputs.env_name }}
appinsights-staging-key: ${{ secrets.APPINSIGHTS_STAGING_KEY }}
appinsights-prod-key: ${{ secrets.APPINSIGHTS_PROD_KEY }}
version: ${{ needs.pre_job.outputs.version }}
test-admin-user: ${{ secrets.TEST_ADMIN_USERNAME }}
test-admin-password: ${{ secrets.TEST_ADMIN_PASSWORD }}
test-sender-user: ${{ secrets.TEST_SENDER_USERNAME }}
test-sender-password: ${{ secrets.TEST_SENDER_PASSWORD }}
test-receiver-user: ${{ secrets.TEST_RECEIVER_USERNAME }}
test-receiver-password: ${{ secrets.TEST_RECEIVER_PASSWORD }}
deploy_infrastructure:
name: "Deploy Infrastructure: ${{ needs.pre_job.outputs.env_name }}"
needs:
- pre_job
if: |
needs.pre_job.outputs.env_name == 'demo1' ||
needs.pre_job.outputs.env_name == 'demo2' ||
needs.pre_job.outputs.env_name == 'demo3'
environment: ${{ needs.pre_job.outputs.env_name }}
concurrency: demo
runs-on: ubuntu-latest
steps:
- name: Check out changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Use specific version of Terraform
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
with:
terraform_version: 1.7.4
terraform_wrapper: false
- name: Connect to VPN and login to Azure
uses: ./.github/actions/vpn-azure
with:
env-name: ${{ needs.pre_job.outputs.env_name }}
sp-creds: ${{ secrets.SERVICE_PRINCIPAL_CREDS }}
tf-auth: true
- name: Provision demo environment
uses: ./.github/actions/demo-env
with:
env-name: ${{ needs.pre_job.outputs.env_name }}
github-token: ${{ secrets.DEMO_ENV }}
backup-age-limit: 7200
backup-from: staging
approve_router_release:
name: "Approve Router Release: ${{ needs.pre_job.outputs.env_name }}"
needs:
- pre_job
- build_router_release
- deploy_infrastructure
if: |
always() &&
!cancelled() &&
!failure() &&
needs.pre_job.outputs.has_router_change == 'true'
environment: ${{ needs.pre_job.outputs.env_name }}-router
concurrency: ${{ needs.pre_job.outputs.env_name }}-router
runs-on: ubuntu-latest
steps:
- name: Check out changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Login to Azure
if: |
needs.pre_job.outputs.has_router_change == 'true' ||
needs.pre_job.outputs.has_frontend_change == 'true'
uses: ./.github/actions/vpn-azure
with:
env-name: ${{ needs.pre_job.outputs.env_name }}
sp-creds: ${{ secrets.SERVICE_PRINCIPAL_CREDS }}
- name: Get function app checksum
env:
checksum_validation: ${{ vars.CHECKSUM_VALIDATION }}
if: needs.pre_job.outputs.has_router_change == 'true' && env.checksum_validation == 'true'
uses: JosiahSiegel/checksum-validate-action@ebdf8c12c00912d18de93c483b935d51582f9236
## DevSecOps - Aquia (Replace) - uses: ./.github/actions/checksum-validate-action
with:
key: backend
input: $(az functionapp config appsettings list -g prime-data-hub-${{ needs.pre_job.outputs.env_name }} -n pdh${{ needs.pre_job.outputs.env_name }}-functionapp -o tsv | sort)
approve_frontend_release:
name: "Approve Frontend Release: ${{ needs.pre_job.outputs.env_name }}"
needs:
- pre_job
- build_frontend_react_release
if: |
always() &&
!cancelled() &&
!failure() &&
needs.pre_job.outputs.has_frontend_change == 'true'
environment: ${{ needs.pre_job.outputs.env_name }}-frontend
concurrency: ${{ needs.pre_job.outputs.env_name }}-frontend
runs-on: ubuntu-latest
steps:
- name: Check out changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
deploy_router_release:
name: "Deploy Router Release: ${{ needs.pre_job.outputs.env_name }}"
needs:
- pre_job
- approve_router_release
if: |
always() &&
!cancelled() &&
!failure() &&
needs.pre_job.outputs.has_router_change == 'true'
environment: ${{ needs.pre_job.outputs.env_name }}
concurrency: ${{ needs.pre_job.outputs.env_name }}
runs-on: ubuntu-latest
steps:
- name: Check out changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Connect to VPN and login to Azure
uses: ./.github/actions/vpn-azure
with:
env-name: ${{ needs.pre_job.outputs.env_name }}
tls-key: ${{ secrets.TLS_KEY }}
ca-cert: ${{ secrets.CA_CRT}}
user-crt: ${{ secrets.USER_CRT }}
user-key: ${{ secrets.USER_KEY }}
sp-creds: ${{ secrets.SERVICE_PRINCIPAL_CREDS }}
dns-ip: ${{ needs.pre_job.outputs.dns_ip }}
- name: Deploy backend
env:
checksum_validation: ${{ vars.CHECKSUM_VALIDATION }}
uses: ./.github/actions/deploy-backend
with:
env-name: ${{ needs.pre_job.outputs.env_name }}
dct-root-pass: ${{ secrets.DCT_ROOT_PASS }}
dct-repo-pass: ${{ secrets.DCT_REPO_PASS }}
version: ${{ needs.pre_job.outputs.version }}
checksum-validation: ${{ env.checksum_validation }}
deploy_frontend_release:
name: "Deploy Frontend Release: ${{ needs.pre_job.outputs.env_name }}"
needs:
- pre_job
- approve_frontend_release
if: |
always() &&
!cancelled() &&
!failure() &&
needs.pre_job.outputs.has_frontend_change == 'true'
environment: ${{ needs.pre_job.outputs.env_name }}
concurrency: ${{ needs.pre_job.outputs.env_name }}
runs-on: ubuntu-latest
steps:
- name: Check out changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Connect to VPN and login to Azure
uses: ./.github/actions/vpn-azure
with:
env-name: ${{ needs.pre_job.outputs.env_name }}
tls-key: ${{ secrets.TLS_KEY }}
ca-cert: ${{ secrets.CA_CRT}}
user-crt: ${{ secrets.USER_CRT }}
user-key: ${{ secrets.USER_KEY }}
sp-creds: ${{ secrets.SERVICE_PRINCIPAL_CREDS }}
dns-ip: ${{ needs.pre_job.outputs.dns_ip }}
- name: Deploy frontend
uses: ./.github/actions/deploy-frontend
with:
env-name: ${{ needs.pre_job.outputs.env_name }}
version: ${{ needs.pre_job.outputs.version }}