1717 default : " "
1818 aws-region :
1919 description : >-
20- Override the AWS Region
20+ Override the AWS Region destination for uploaded artifacts.
21+ Default to `us-east-1`.
2122 default : us-east-1
2223 type : choice
2324 options :
@@ -29,12 +30,64 @@ permissions:
2930 id-token : write # This is required for requesting the AWS IAM OIDC JWT
3031 contents : write # This is required for actions/checkout
3132
33+ env :
34+ AWS_REGION : ${{ inputs.aws-region }}
35+
3236defaults :
3337 run :
3438 shell : bash
3539
3640jobs :
41+ notify-start :
42+ runs-on : ubuntu-24.04-arm
43+ steps :
44+ - name : Setup node
45+ uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
46+ with :
47+ node-version : 24.x
48+
49+ - name : Get role ARN
50+ id : get-role-arn
51+ # It doesn't matter whether we use prod or non-prod account here as either works.
52+ # Common platform SSM parameters (such as Webhook URLs) exist in both accounts.
53+ run : |
54+ role_arn="${{ secrets.NON_PROD_ACCOUNT_GHA_ROLE_ARN }}"
55+ echo "::add-mask::$role_arn"
56+ echo "role-arn=$role_arn" >> "$GITHUB_OUTPUT"
57+
58+ - name : Assume role to AWS
59+ uses : aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
60+ with :
61+ role-to-assume : ${{ steps.get-role-arn.outputs.role-arn }}
62+ role-session-name : get-sops-slack-webhook-${{ github.run_id }}-${{ github.run_attempt }}
63+ aws-region : ${{ inputs.aws-region }}
64+
65+ - name : Load Start Slack webhook
66+ uses : cmsgov/cdap/actions/aws-params-env-action@main
67+ with :
68+ params : |
69+ SLACK_WEBHOOK_URL=/bfd/platform/alerting/sensitive/slack/bfd-notices/webhook
70+
71+ - name : Slack - STARTED
72+ uses : slackapi/slack-github-action@03ea5433c137af7c0495bc0cad1af10403fc800c # v3.0.2
73+ with :
74+ webhook : ${{ env.SLACK_WEBHOOK_URL }}
75+ webhook-type : incoming-webhook
76+ payload : |
77+ {
78+ "attachments": [
79+ {
80+ "color": "yellow",
81+ "title": "BFD Release STARTED",
82+ "text": "Version: *${{ inputs.release-version || 'latest' }}*\n
83+ Triggered by: ${{ github.actor }}\n
84+ <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow Run>"
85+ }
86+ ]
87+ }
88+
3789 build-release :
90+ needs : notify-start
3891 if : ${{ github.ref_name == github.event.repository.default_branch }}
3992 uses : ./.github/workflows/build-release.yml
4093 with :
4598
4699 deploy-platform :
47100 uses : ./.github/workflows/deploy-platform-services.yml
48- needs : [ build-release]
101+ needs : build-release
49102 strategy :
50103 matrix :
51104 account-type : ["prod", "non-prod"]
@@ -77,3 +130,85 @@ jobs:
77130 bfd-env : prod
78131 git-ref : refs/tags/${{ needs.build-release.outputs.bfd_release }}
79132 secrets : inherit
133+
134+ workflow-summary :
135+ name : Final Slack Summary
136+ runs-on : ubuntu-24.04-arm
137+ needs :
138+ - build-release
139+ - deploy-platform
140+ - deploy-to-test
141+ - deploy-to-sandbox
142+ - deploy-to-prod
143+ if : !cancelled()
144+ steps :
145+ - name : Get role ARN
146+ id : get-role-arn
147+ # It doesn't matter whether we use prod or non-prod account here as either works.
148+ # Common platform SSM parameters (such as Webhook URLs) exist in both accounts.
149+ run : |
150+ role_arn="${{ secrets.NON_PROD_ACCOUNT_GHA_ROLE_ARN }}"
151+ echo "::add-mask::$role_arn"
152+ echo "role-arn=$role_arn" >> "$GITHUB_OUTPUT"
153+
154+ - name : Assume role to AWS
155+ uses : aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
156+ with :
157+ role-to-assume : ${{ steps.get-role-arn.outputs.role-arn }}
158+ role-session-name : get-sops-slack-webhook-${{ github.run_id }}-${{ github.run_attempt }}
159+ aws-region : ${{ inputs.aws-region }}
160+
161+ - name : Load Slack webhook
162+ uses : cmsgov/cdap/actions/aws-params-env-action@main
163+ with :
164+ params : |
165+ SLACK_WEBHOOK_URL=/bfd/platform/alerting/sensitive/slack/bfd-notices/webhook
166+
167+ - name : Compute status
168+ id : status
169+ run : |
170+ STAGES=("build-release" "deploy-platform" "deploy-to-test" "deploy-to-sandbox" "deploy-to-prod")
171+ RESULTS='${{ toJSON(needs) }}'
172+
173+ FINAL_STATUS="SUCCESS"
174+ FAILED_STAGE="none"
175+ COLOR="good"
176+
177+ for STAGE in "${STAGES[@]}"; do
178+ RESULT=$(echo $RESULTS | jq -r ".[\"$STAGE\"].result")
179+ if [[ "$RESULT" != "success" && "$RESULT" != "skipped" ]]; then
180+ FINAL_STATUS="FAILED"
181+ FAILED_STAGE=$STAGE
182+ COLOR="danger"
183+ break
184+ fi
185+ done
186+
187+ echo "status=$FINAL_STATUS" >> $GITHUB_OUTPUT
188+ echo "failed_stage=$FAILED_STAGE" >> $GITHUB_OUTPUT
189+ echo "color=$COLOR" >> $GITHUB_OUTPUT
190+
191+ - name : Slack - FINAL SUMMARY
192+ uses : slackapi/slack-github-action@03ea5433c137af7c0495bc0cad1af10403fc800c # v3.0.2
193+ with :
194+ webhook : ${{ env.SLACK_WEBHOOK_URL }}
195+ webhook-type : incoming-webhook
196+ payload : |
197+ {
198+ "attachments": [
199+ {
200+ "color": "${{ steps.status.outputs.color }}",
201+ "title": "${{ steps.status.outputs.status == 'SUCCESS' && 'BFD Deploy SUCCESS' || 'BFD Deploy FAILED' }}",
202+ "text": "${{ steps.status.outputs.status == 'FAILED' && '<!subteam^BFD-ENGINEERS|@bfd-engineers>' || '' }}\n
203+ *Status:* ${{ steps.status.outputs.status }}\n
204+ *Version:* ${{ inputs.release-version || 'latest' }}\n
205+ *Failed Stage:* ${{ steps.status.outputs.failed_stage }}\n\n
206+ *Build:* ${{ needs.build-release.result }}\n
207+ *Platform:* ${{ needs.deploy-platform.result }}\n
208+ *Test:* ${{ needs.deploy-to-test.result }}\n
209+ *Sandbox:* ${{ needs.deploy-to-sandbox.result }}\n
210+ *Prod:* ${{ needs.deploy-to-prod.result }}\n\n
211+ <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Full Report>"
212+ }
213+ ]
214+ }
0 commit comments