-
Notifications
You must be signed in to change notification settings - Fork 40
213 lines (200 loc) · 6.75 KB
/
Copy pathdeploy-env-services.yml
File metadata and controls
213 lines (200 loc) · 6.75 KB
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
---
name: "Deploy Environment Services"
on:
workflow_dispatch:
inputs:
bfd-env:
description: The BFD environment to deploy services to
required: true
services:
description: Comma-separated list of services to deploy
default: >-
config,
cluster,
database,
eft,
locust,
migrator,
ccw-pipeline,
npi-pipeline,
rda-pipeline,
server,
ccw-pipeline-metrics,
rda-pipeline-metrics,
server-metrics,
ccw-pipeline-alarms,
rda-pipeline-alarms,
server-alarms
required: true
aws-region:
description: >-
Override the AWS Region
default: us-east-1
type: choice
options:
- us-east-1
- us-west-2
required: true
skip-applies:
description: >-
If true, skips the apply step for each Terraservice such that only the plans are generated
default: false
required: false
type: boolean
permissions:
id-token: write # This is required for requesting the AWS IAM OIDC JWT
contents: write # This is required for actions/checkout
env:
DEPLOY_JOBS_MATRIX_JSON: |
{
"01": [
{ "layer": "01", "service": "config", "runner": "lambda" }
],
"02": [
{ "layer": "02", "service": "cluster", "runner": "lambda" },
{ "layer": "02", "service": "database", "runner": "small" }
],
"03": [
{ "layer": "03", "service": "locust", "runner": "lambda" },
{ "layer": "03", "service": "migrator", "runner": "small" }
],
"04": [
{ "layer": "04", "service": "ccw-pipeline", "runner": "lambda" },
{ "layer": "04", "service": "npi-pipeline", "runner": "lambda" },
{ "layer": "04", "service": "rda-pipeline", "runner": "lambda" },
{ "layer": "04", "service": "server", "runner": "lambda" }
],
"05": [
{ "layer": "05", "service": "ccw-pipeline-metrics", "runner": "lambda" },
{ "layer": "05", "service": "rda-pipeline-metrics", "runner": "lambda" },
{ "layer": "05", "service": "server-metrics", "runner": "lambda" }
],
"06": [
{ "layer": "06", "service": "ccw-pipeline-alarms", "runner": "lambda" },
{ "layer": "06", "service": "rda-pipeline-alarms", "runner": "lambda" },
{ "layer": "06", "service": "server-alarms", "runner": "lambda" }
]
}
PARENT_ENV_ACCOUNT_MAP: |
{
"test": "non-prod",
"sandbox": "prod",
"prod": "prod"
}
defaults:
run:
shell: bash
jobs:
setup:
runs-on: ubuntu-24.04
outputs:
account-type: ${{ steps.get-account-type.outputs.account-type }}
deploy-jobs-matrix-json: ${{ steps.get-deploy-jobs-matrix-json.outputs.deploy-jobs-matrix-json }}
steps:
- name: Get account type from parent env
id: get-account-type
run: |
parent_env="$(echo "${{ inputs.bfd-env }}" | grep -Po '(prod|sandbox|test)$')"
account_type="$(jq -r --arg parent_env "$parent_env" '.[$parent_env]' <<<"$PARENT_ENV_ACCOUNT_MAP")"
echo "account-type=$account_type" >> "$GITHUB_OUTPUT"
- name: Get filtered deploy jobs matrix JSON as output
id: get-deploy-jobs-matrix-json
env:
SERVICES: ${{ inputs.services }}
run: |
deploy_jobs_matrix_json="$(
jq -c --arg services "$SERVICES" '
# Convert the CSV list of services into an array
($services | split(",") | map(gsub("^\\s+|\\s+$"; ""))) as $filterServices
| to_entries
| map(
.value |= map(select(.service | IN($filterServices[])))
)
| from_entries
' <<<"$DEPLOY_JOBS_MATRIX_JSON"
)"
echo "deploy-jobs-matrix-json=$deploy_jobs_matrix_json" >> "$GITHUB_OUTPUT"
deploy-layer-01:
uses: ./.github/workflows/_deploy-env-service-layer.yml
needs: [setup]
permissions:
contents: read
id-token: write
with:
layer-level: '01'
bfd-env: ${{ inputs.bfd-env }}
account-type: ${{ needs.setup.outputs.account-type }}
matrix-json: ${{ needs.setup.outputs.deploy-jobs-matrix-json }}
aws-region: ${{ inputs.aws-region }}
skip-applies: ${{ inputs.skip-applies }}
secrets: inherit
deploy-layer-02:
uses: ./.github/workflows/_deploy-env-service-layer.yml
needs: [setup, deploy-layer-01]
permissions:
contents: read
id-token: write
with:
layer-level: '02'
bfd-env: ${{ inputs.bfd-env }}
account-type: ${{ needs.setup.outputs.account-type }}
matrix-json: ${{ needs.setup.outputs.deploy-jobs-matrix-json }}
aws-region: ${{ inputs.aws-region }}
skip-applies: ${{ inputs.skip-applies }}
secrets: inherit
deploy-layer-03:
uses: ./.github/workflows/_deploy-env-service-layer.yml
needs: [setup, deploy-layer-02]
permissions:
contents: read
id-token: write
with:
layer-level: '03'
bfd-env: ${{ inputs.bfd-env }}
account-type: ${{ needs.setup.outputs.account-type }}
matrix-json: ${{ needs.setup.outputs.deploy-jobs-matrix-json }}
aws-region: ${{ inputs.aws-region }}
skip-applies: ${{ inputs.skip-applies }}
secrets: inherit
deploy-layer-04:
uses: ./.github/workflows/_deploy-env-service-layer.yml
needs: [setup, deploy-layer-03]
permissions:
contents: read
id-token: write
with:
layer-level: '04'
bfd-env: ${{ inputs.bfd-env }}
account-type: ${{ needs.setup.outputs.account-type }}
matrix-json: ${{ needs.setup.outputs.deploy-jobs-matrix-json }}
aws-region: ${{ inputs.aws-region }}
skip-applies: ${{ inputs.skip-applies }}
secrets: inherit
deploy-layer-05:
uses: ./.github/workflows/_deploy-env-service-layer.yml
needs: [setup, deploy-layer-04]
permissions:
contents: read
id-token: write
with:
layer-level: '05'
bfd-env: ${{ inputs.bfd-env }}
account-type: ${{ needs.setup.outputs.account-type }}
matrix-json: ${{ needs.setup.outputs.deploy-jobs-matrix-json }}
aws-region: ${{ inputs.aws-region }}
skip-applies: ${{ inputs.skip-applies }}
secrets: inherit
deploy-layer-06:
uses: ./.github/workflows/_deploy-env-service-layer.yml
needs: [setup, deploy-layer-05]
permissions:
contents: read
id-token: write
with:
layer-level: '06'
bfd-env: ${{ inputs.bfd-env }}
account-type: ${{ needs.setup.outputs.account-type }}
matrix-json: ${{ needs.setup.outputs.deploy-jobs-matrix-json }}
aws-region: ${{ inputs.aws-region }}
skip-applies: ${{ inputs.skip-applies }}
secrets: inherit