-
Notifications
You must be signed in to change notification settings - Fork 40
192 lines (174 loc) · 6.53 KB
/
Copy pathrelease-and-deploy-bfd.yml
File metadata and controls
192 lines (174 loc) · 6.53 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
---
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
push:
branches:
- feature/BFD-4248_GitHub-BuildAndDeploy-Slack-Notification
permissions:
id-token: write # This is required for requesting the AWS IAM OIDC JWT
contents: write # This is required for actions/checkout
defaults:
run:
shell: bash
jobs:
notify-start:
runs-on: ubuntu-latest
steps:
- name: Setup node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24.x
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
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: ${{ env.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: Slack - STARTED
uses: slackapi/slack-github-action@03ea5433c137af7c0495bc0cad1af10403fc800c # v3.0.2
with:
payload: |
{
"attachments": [
{
"color": "#FFFF00",
"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>"
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}
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-latest
needs:
- build-release
- deploy-platform
- deploy-to-test
- deploy-to-sandbox
- deploy-to-prod
if: always()
steps:
- name: Load Slack webhook
uses: cmsgov/cdap/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ github.event.inputs.aws-region || 'us-east-1' }}
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:
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>"
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}