-
Notifications
You must be signed in to change notification settings - Fork 40
214 lines (193 loc) · 7.65 KB
/
Copy pathrelease-and-deploy-bfd.yml
File metadata and controls
214 lines (193 loc) · 7.65 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
214
---
name: "Release and Deploy BFD"
on:
workflow_dispatch:
inputs:
release-version:
description: >-
Override the release version. Default to promoting the current
X.Y.Z-SNAPSHOT to X.Y.Z when empty.
required: false
default: ""
development-version:
description: >-
Override the next development iteration version.
Default to X.(Y+1).0-SNAPSHOT of the release version X.Y.Z when empty.
required: false
default: ""
aws-region:
description: >-
Override the AWS Region destination for uploaded artifacts.
Default to `us-east-1`.
default: us-east-1
type: choice
options:
- us-east-1
- us-west-2
required: true
permissions:
id-token: write # This is required for requesting the AWS IAM OIDC JWT
contents: write # This is required for actions/checkout
env:
AWS_REGION: ${{ inputs.aws-region }}
defaults:
run:
shell: bash
jobs:
notify-start:
runs-on: ubuntu-24.04-arm
steps:
- name: Setup node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24.x
- name: Get role ARN
id: get-role-arn
# It doesn't matter whether we use prod or non-prod account here as either works.
# Common platform SSM parameters (such as Webhook URLs) exist in both accounts.
run: |
role_arn="${{ secrets.NON_PROD_ACCOUNT_GHA_ROLE_ARN }}"
echo "::add-mask::$role_arn"
echo "role-arn=$role_arn" >> "$GITHUB_OUTPUT"
- name: Assume role to AWS
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
role-to-assume: ${{ steps.get-role-arn.outputs.role-arn }}
role-session-name: get-sops-slack-webhook-${{ github.run_id }}-${{ github.run_attempt }}
aws-region: ${{ inputs.aws-region }}
- name: Load Start Slack webhook
uses: cmsgov/cdap/actions/aws-params-env-action@main
with:
params: |
SLACK_WEBHOOK_URL=/bfd/platform/alerting/sensitive/slack/bfd-notices/webhook
- name: Slack - STARTED
uses: slackapi/slack-github-action@03ea5433c137af7c0495bc0cad1af10403fc800c # v3.0.2
with:
webhook: ${{ env.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"attachments": [
{
"color": "yellow",
"title": "BFD Release STARTED",
"text": "Version: *${{ inputs.release-version || 'latest' }}*\n
Triggered by: ${{ github.actor }}\n
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow Run>"
}
]
}
build-release:
needs: notify-start
if: ${{ github.ref_name == github.event.repository.default_branch }}
uses: ./.github/workflows/build-release.yml
with:
releaseVersion: ${{ inputs.release-version }}
developmentVersion: ${{ inputs.development-version }}
awsRegion: ${{ inputs.aws-region }}
secrets: inherit
deploy-platform:
uses: ./.github/workflows/deploy-platform-services.yml
needs: build-release
strategy:
matrix:
account-type: ["prod", "non-prod"]
with:
account-type: ${{ matrix.account-type }}
git-ref: refs/tags/${{ needs.build-release.outputs.bfd_release }}
secrets: inherit
deploy-to-test:
uses: ./.github/workflows/deploy-env-services.yml
needs: [build-release, deploy-platform]
with:
bfd-env: test
git-ref: refs/tags/${{ needs.build-release.outputs.bfd_release }}
secrets: inherit
deploy-to-sandbox:
uses: ./.github/workflows/deploy-env-services.yml
needs: [build-release, deploy-to-test]
with:
bfd-env: sandbox
git-ref: refs/tags/${{ needs.build-release.outputs.bfd_release }}
secrets: inherit
deploy-to-prod:
uses: ./.github/workflows/deploy-env-services.yml
needs: [build-release, deploy-to-sandbox]
with:
bfd-env: prod
git-ref: refs/tags/${{ needs.build-release.outputs.bfd_release }}
secrets: inherit
workflow-summary:
name: Final Slack Summary
runs-on: ubuntu-24.04-arm
needs:
- build-release
- deploy-platform
- deploy-to-test
- deploy-to-sandbox
- deploy-to-prod
if: ${{ !cancelled() }}
steps:
- name: Get role ARN
id: get-role-arn
# It doesn't matter whether we use prod or non-prod account here as either works.
# Common platform SSM parameters (such as Webhook URLs) exist in both accounts.
run: |
role_arn="${{ secrets.NON_PROD_ACCOUNT_GHA_ROLE_ARN }}"
echo "::add-mask::$role_arn"
echo "role-arn=$role_arn" >> "$GITHUB_OUTPUT"
- name: Assume role to AWS
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
role-to-assume: ${{ steps.get-role-arn.outputs.role-arn }}
role-session-name: get-sops-slack-webhook-${{ github.run_id }}-${{ github.run_attempt }}
aws-region: ${{ inputs.aws-region }}
- name: Load Slack webhook
uses: cmsgov/cdap/actions/aws-params-env-action@main
with:
params: |
SLACK_WEBHOOK_URL=/bfd/platform/alerting/sensitive/slack/bfd-notices/webhook
- name: Compute status
id: status
run: |
STAGES=("build-release" "deploy-platform" "deploy-to-test" "deploy-to-sandbox" "deploy-to-prod")
RESULTS='${{ toJSON(needs) }}'
FINAL_STATUS="SUCCESS"
FAILED_STAGE="none"
COLOR="good"
for STAGE in "${STAGES[@]}"; do
RESULT=$(echo $RESULTS | jq -r ".[\"$STAGE\"].result")
if [[ "$RESULT" != "success" && "$RESULT" != "skipped" ]]; then
FINAL_STATUS="FAILED"
FAILED_STAGE=$STAGE
COLOR="danger"
break
fi
done
echo "status=$FINAL_STATUS" >> $GITHUB_OUTPUT
echo "failed_stage=$FAILED_STAGE" >> $GITHUB_OUTPUT
echo "color=$COLOR" >> $GITHUB_OUTPUT
- name: Slack - FINAL SUMMARY
uses: slackapi/slack-github-action@03ea5433c137af7c0495bc0cad1af10403fc800c # v3.0.2
with:
webhook: ${{ env.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"attachments": [
{
"color": "${{ steps.status.outputs.color }}",
"title": "${{ steps.status.outputs.status == 'SUCCESS' && 'BFD Deploy SUCCESS' || 'BFD Deploy FAILED' }}",
"text": "${{ steps.status.outputs.status == 'FAILED' && '<!subteam^BFD-ENGINEERS|@bfd-engineers>' || '' }}\n
*Status:* ${{ steps.status.outputs.status }}\n
*Version:* ${{ inputs.release-version || 'latest' }}\n
*Failed Stage:* ${{ steps.status.outputs.failed_stage }}\n\n
*Build:* ${{ needs.build-release.result }}\n
*Platform:* ${{ needs.deploy-platform.result }}\n
*Test:* ${{ needs.deploy-to-test.result }}\n
*Sandbox:* ${{ needs.deploy-to-sandbox.result }}\n
*Prod:* ${{ needs.deploy-to-prod.result }}\n\n
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Full Report>"
}
]
}