-
Notifications
You must be signed in to change notification settings - Fork 1
[NDR-313] Add slack notification for workflow failures #880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9d3c522
[NDR-313] Testing slack notification
megan-bower4 553a072
[NDR-313] Revert version
megan-bower4 ee73d15
[NDR-313] Add workflow_call block to pass secret
megan-bower4 b72741a
[NDR-313] Add environment settings to workflow
megan-bower4 06970f2
[NDR-313] Update env reference
megan-bower4 cfd8de1
[NDR-313] Update slack message
megan-bower4 6f26646
[NDR-313] Use json in slack message
megan-bower4 fcfc477
[NDR-313] Temporary test failure to test slack notification
megan-bower4 cdb81fb
[NDR-313] Move slack notifiacation to merge to main workflows only
megan-bower4 7672370
[NDR-313] Add slack notifiacation to other merge to main workflows
megan-bower4 751b663
[NDR-313] Test branch name in message
megan-bower4 e90dffb
[NDR-313] Remove False assertion
megan-bower4 fa7116b
[NDR-313] Only alert on merge to main failures not pull requests
megan-bower4 8990998
[NDR-313] Update link with actual workflow name
megan-bower4 52c685b
[NDR-313] Remove false assertion
megan-bower4 2eecc27
[NDR-313] Update step name
megan-bower4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,3 +78,91 @@ jobs: | |
| sandbox: ndr-dev | ||
| secrets: | ||
| AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }} | ||
|
|
||
| notify-slack: | ||
| runs-on: ubuntu-latest | ||
| needs: [check_packages, run_tests, publish_all_lambda_layers, deploy_all_lambdas, deploy_data_collection] | ||
| if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| steps: | ||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v5 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} | ||
| role-skip-session-tagging: true | ||
| aws-region: ${{ vars.AWS_REGION }} | ||
| mask-aws-account-id: true | ||
|
|
||
| - name: Get slack bot token from SSM parameter store | ||
| id: ssm-parameters | ||
| run: | | ||
| slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text) | ||
| echo "::add-mask::$slack_bot_token" | ||
| echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV | ||
|
|
||
| - name: Send Slack Notification | ||
| uses: slackapi/[email protected] | ||
| with: | ||
| method: chat.postMessage | ||
| token: ${{ env.SLACK_BOT_TOKEN }} | ||
| payload: | | ||
| { | ||
| "channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}", | ||
| "attachments": [ | ||
| { | ||
| "color": "#ff0000", | ||
| "blocks": [ | ||
robg-test marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| "type": "header", | ||
| "text": { | ||
| "type": "plain_text", | ||
| "text": "❌ Workflow `${{ github.workflow }}` failed" | ||
| } | ||
| }, | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": "*Triggered by:* `${{ github.actor }}`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>" | ||
| } | ||
| }, | ||
| { | ||
| "type": "divider" | ||
| }, | ||
| { | ||
| "type": "section", | ||
| "fields": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "*check_packages:* ${{ needs.check_packages.result == 'success' && ':white_check_mark:' || ':x:' }}" | ||
| }, | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "*run_tests:* ${{ needs.run_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" | ||
| }, | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "*publish_all_lambda_layers:* ${{ needs.publish_all_lambda_layers.result == 'success' && ':white_check_mark:' || ':x:' }}" | ||
| }, | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "*deploy_all_lambdas:* ${{ needs.deploy_all_lambdas.result == 'success' && ':white_check_mark:' || ':x:' }}" | ||
| }, | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "*deploy_data_collection:* ${{ needs.deploy_data_collection.result == 'success' && ':white_check_mark:' || ':x:' }}" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "type": "context", | ||
| "elements": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "Environment: `development` | Sandbox: `ndr-dev`" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ jobs: | |
| sandbox: ndr-dev | ||
| secrets: | ||
| AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }} | ||
|
|
||
| services-fhir-api-e2etest: | ||
| uses: ./.github/workflows/base-e2e-fhir-backendtest.yml | ||
| with: | ||
|
|
@@ -32,3 +33,79 @@ jobs: | |
| sandbox: ndr-dev | ||
| secrets: | ||
| AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }} | ||
|
|
||
| notify-slack: | ||
| runs-on: ubuntu-latest | ||
| needs: [services-e2etest, services-fhir-api-e2etest] | ||
| if: failure() | ||
| steps: | ||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v5 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} | ||
| role-skip-session-tagging: true | ||
| aws-region: ${{ vars.AWS_REGION }} | ||
| mask-aws-account-id: true | ||
|
|
||
| - name: Get slack bot token from SSM parameter store | ||
| id: ssm-parameters | ||
| run: | | ||
| slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text) | ||
| echo "::add-mask::$slack_bot_token" | ||
| echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV | ||
|
|
||
| - name: Send Slack Notification | ||
| uses: slackapi/[email protected] | ||
| with: | ||
| method: chat.postMessage | ||
| token: ${{ env.SLACK_BOT_TOKEN }} | ||
| payload: | | ||
| { | ||
| "channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}", | ||
| "attachments": [ | ||
| { | ||
| "color": "#ff0000", | ||
| "blocks": [ | ||
| { | ||
| "type": "header", | ||
| "text": { | ||
| "type": "plain_text", | ||
| "text": "❌ Workflow `${{ github.workflow }}` failed" | ||
| } | ||
| }, | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": "*Triggered by:* `${{ github.actor }}`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>" | ||
| } | ||
| }, | ||
| { | ||
| "type": "divider" | ||
| }, | ||
| { | ||
| "type": "section", | ||
| "fields": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "*services-e2etest:* ${{ needs.services-e2etest.result == 'success' && ':white_check_mark:' || ':x:' }}" | ||
| }, | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "*services-fhir-api-e2etest:* ${{ needs.services-fhir-api-e2etest.result == 'success' && ':white_check_mark:' || ':x:' }}" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "type": "context", | ||
| "elements": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "Environment: `${{ needs.services-fhir-api-e2etest.outputs.environment }}` | Sandbox: `${{ needs.services-fhir-api-e2etest.outputs.sandbox }}`" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,3 +29,72 @@ jobs: | |
| AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }} | ||
| CYPRESS_ODSCODE: ${{ secrets.CYPRESS_ODSCODE }} | ||
| CYPRESS_KEY: ${{ secrets.CYPRESS_KEY }} | ||
|
|
||
| notify-slack: | ||
| runs-on: ubuntu-latest | ||
| needs: [smoketest] | ||
| if: failure() | ||
| steps: | ||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v5 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} | ||
| aws-region: ${{ vars.AWS_REGION }} | ||
|
|
||
| - name: Get slack bot token from SSM parameter store | ||
| run: | | ||
| slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text) | ||
| echo "::add-mask::$slack_bot_token" | ||
| echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV | ||
|
|
||
| - name: Send Slack Notification | ||
| uses: slackapi/[email protected] | ||
| with: | ||
| method: chat.postMessage | ||
| token: ${{ env.SLACK_BOT_TOKEN }} | ||
| payload: | | ||
| { | ||
| "channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}", | ||
| "attachments": [ | ||
| { | ||
| "color": "#ff0000", | ||
| "blocks": [ | ||
| { | ||
| "type": "header", | ||
| "text": { | ||
| "type": "plain_text", | ||
| "text": "❌ Workflow `${{ github.workflow }}` failed" | ||
| } | ||
| }, | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": "*Triggered by:* `${{ github.actor }}`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>" | ||
| } | ||
| }, | ||
| { | ||
| "type": "divider" | ||
| }, | ||
| { | ||
| "type": "section", | ||
| "fields": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "*smoketest:* ${{ needs.smoketest.result == 'success' && ':white_check_mark:' || ':x:' }}" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "type": "context", | ||
| "elements": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "Environment: `development` | Sandbox: `ndr-dev`" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.