-
Notifications
You must be signed in to change notification settings - Fork 5
190 lines (163 loc) · 5.88 KB
/
prod_cd_citizen-auth.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
name: Continuous Delivery on prod citizen-auth
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "src/domains/citizen-auth**"
- ".github/workflows/prod**citizen-auth.yml"
permissions:
id-token: write
contents: read
env:
DIR: "src/domains/citizen-auth"
ARM_USE_OIDC: true
ARM_USE_AZUREAD: true
ARM_STORAGE_USE_AZUREAD: true
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
jobs:
terraform_plan_job:
name: Terraform Plan
runs-on: self-hosted
environment: prod-ci
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
fetch-depth: 0
- name: Azure Login
id: az_login
uses: azure/login@81e1d9f360e1ba776e93b8ead1c4320761356b2a # v2.0.0
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Set Terraform Version
id: env_tf_version
run: |
echo "terraform_version=$(cat .terraform-version)" >> $GITHUB_OUTPUT
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36
id: terraform_setup
name: Setup Terraform
with:
terraform_version: ${{ steps.env_tf_version.outputs.terraform_version}}
terraform_wrapper: true
- name: Terraform plan common
shell: bash
working-directory: ${{ env.DIR }}-common
env:
AZURE_ENVIRONMENT: prod
run: |
bash ./terraform.sh plan ${{ env.AZURE_ENVIRONMENT }} -lock-timeout=3000s -out=tfplan-${{ env.AZURE_ENVIRONMENT }}-${{ github.sha }} -input=false
- name: Terraform plan weu-beta
shell: bash
working-directory: ${{ env.DIR }}-app
env:
AZURE_ENVIRONMENT: weu-beta
run: |
bash ./terraform.sh plan ${{ env.AZURE_ENVIRONMENT }} -lock-timeout=3000s -out=tfplan-${{ env.AZURE_ENVIRONMENT }}-${{ github.sha }} -input=false
- name: Terraform plan weu-prod01
shell: bash
working-directory: ${{ env.DIR }}-app
env:
AZURE_ENVIRONMENT: weu-prod01
run: |
bash ./terraform.sh plan ${{ env.AZURE_ENVIRONMENT }} -lock-timeout=3000s -out=tfplan-${{ env.AZURE_ENVIRONMENT }}-${{ github.sha }} -input=false
- uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
id: artifact_upload
name: Upload plans as artifacts
with:
name: tfplan-output
if-no-files-found: error
path: |
**/tfplan-prod-*
**/tfplan-weu-beta-*
**/tfplan-weu-prod01-*
outputs:
terraform_version: ${{ steps.env_tf_version.outputs.terraform_version}}
terraform_apply_job:
name: Terraform Apply
runs-on: self-hosted
environment: prod-cd
needs: [terraform_plan_job]
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110
id: artifact_download
name: Download plans as artifact
with:
name: tfplan-output
- name: Azure Login
id: az_login
uses: azure/login@81e1d9f360e1ba776e93b8ead1c4320761356b2a # v2.0.0
with:
client-id: ${{ secrets.AZURE_CLIENT_ID_CD }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36
id: terraform_setup
name: Setup Terraform
with:
terraform_version: ${{ needs.terraform_plan_job.outputs.terraform_version }}
terraform_wrapper: true
- name: Terraform init common
id: terraform_init_common
shell: bash
working-directory: ${{ env.DIR }}-common
env:
AZURE_ENVIRONMENT: prod
run: |
bash ./terraform.sh init ${{ env.AZURE_ENVIRONMENT }}
- name: Terraform apply common
id: terraform_apply_common
shell: bash
working-directory: ${{ env.DIR }}-common
env:
AZURE_ENVIRONMENT: prod
run: |
terraform apply -lock-timeout=3000s -auto-approve -input=false tfplan-${{ env.AZURE_ENVIRONMENT }}-${{ github.sha }}
- name: Terraform init weu-beta
id: terraform_init_weu-beta
shell: bash
working-directory: ${{ env.DIR }}-app
env:
AZURE_ENVIRONMENT: weu-beta
run: |
bash ./terraform.sh init ${{ env.AZURE_ENVIRONMENT }}
- name: Terraform apply weu-beta
id: terraform_apply_weu-beta
shell: bash
working-directory: ${{ env.DIR }}-app
env:
AZURE_ENVIRONMENT: weu-beta
run: |
terraform apply -lock-timeout=3000s -auto-approve -input=false tfplan-${{ env.AZURE_ENVIRONMENT }}-${{ github.sha }}
- name: Terraform init weu-prod01
id: terraform_init_weu-prod01
shell: bash
working-directory: ${{ env.DIR }}-app
env:
AZURE_ENVIRONMENT: weu-prod01
run: |
bash ./terraform.sh init ${{ env.AZURE_ENVIRONMENT }}
- name: Terraform apply weu-prod01
id: terraform_apply_weu-prod01
shell: bash
working-directory: ${{ env.DIR }}-app
env:
AZURE_ENVIRONMENT: weu-prod01
run: |
terraform apply -lock-timeout=3000s -auto-approve -input=false tfplan-${{ env.AZURE_ENVIRONMENT }}-${{ github.sha }}