@@ -160,7 +160,7 @@ jobs:
160160 environment : development
161161 python_version : " 3.11"
162162 secrets :
163- AWS_ASSUME_ROLE : ${{ secrets.AWS_ASSUME_ROLE }}
163+ AWS_ASSUME_ROLE : ${{ secrets.AWS_ASSUME_ROLE }}
164164
165165 deploy_lambdas :
166166 name : Deploy Lambdas
@@ -196,3 +196,72 @@ jobs:
196196 sandbox_name : ${{ needs.set_workspace.outputs.workspace }}
197197 environment : development
198198 secrets : inherit
199+
200+ notify-slack :
201+ runs-on : ubuntu-latest
202+ needs : [terraform_plan_apply, run_lambda_unit_tests, run_ui_unit_tests, run_cypress_tests, publish_lambda_layers, deploy_lambdas, deploy_ui]
203+ if : failure()
204+ steps :
205+ - name : Configure AWS Credentials
206+ uses : aws-actions/configure-aws-credentials@v5
207+ with :
208+ role-to-assume : ${{ secrets.AWS_ASSUME_ROLE }}
209+ aws-region : ${{ vars.AWS_REGION }}
210+
211+ - name : Get slack bot token from SSM parameter store
212+ run : |
213+ slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text)
214+ echo "::add-mask::$slack_bot_token"
215+ echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV
216+
217+ - name : Send Slack Notification
218+ 219+ with :
220+ method : chat.postMessage
221+ token : ${{ env.SLACK_BOT_TOKEN }}
222+ payload : |
223+ {
224+ "channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}",
225+ "attachments": [
226+ {
227+ "color": "#ff0000",
228+ "blocks": [
229+ {
230+ "type": "header",
231+ "text": {
232+ "type": "plain_text",
233+ "text": "❌ Workflow `${{ github.workflow }}` failed"
234+ }
235+ },
236+ {
237+ "type": "section",
238+ "text": {
239+ "type": "mrkdwn",
240+ "text": "*Triggered by:* `Scheduled Job`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>"
241+ }
242+ },
243+ {
244+ "type": "divider"
245+ },
246+ {
247+ "type": "section",
248+ "fields": [
249+ { "type": "mrkdwn", "text": "*terraform_plan_apply:* ${{ needs.terraform_plan_apply.result == 'success' && ':white_check_mark:' || ':x:' }}" },
250+ { "type": "mrkdwn", "text": "*run_lambda_unit_tests:* ${{ needs.run_lambda_unit_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
251+ { "type": "mrkdwn", "text": "*run_ui_unit_tests:* ${{ needs.run_ui_unit_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
252+ { "type": "mrkdwn", "text": "*run_cypress_tests:* ${{ needs.run_cypress_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
253+ { "type": "mrkdwn", "text": "*publish_lambda_layers:* ${{ needs.publish_lambda_layers.result == 'success' && ':white_check_mark:' || ':x:' }}" },
254+ { "type": "mrkdwn", "text": "*deploy_lambdas:* ${{ needs.deploy_lambdas.result == 'success' && ':white_check_mark:' || ':x:' }}" },
255+ { "type": "mrkdwn", "text": "*deploy_ui:* ${{ needs.deploy_ui.result == 'success' && ':white_check_mark:' || ':x:' }}" }
256+ ]
257+ },
258+ {
259+ "type": "context",
260+ "elements": [
261+ { "type": "mrkdwn", "text": "Environment: `development` | Sandbox: `${{ needs.set_workspace.outputs.workspace }}`" }
262+ ]
263+ }
264+ ]
265+ }
266+ ]
267+ }
0 commit comments