send notification on action failure (#3155)

<!-- PR description-->

send a Slack notification if Github Actions fails

#### Does this PR need a docs update or release note?
- [ ]  No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🤖 Supportability/Tests

#### Issue(s)

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
This commit is contained in:
neha_gupta 2023-04-20 01:24:31 +05:30 committed by GitHub
parent 6d022d196a
commit 372f1d5218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,7 +55,7 @@ jobs:
# run the tests
- name: Version Test
run: |
run: |
set -euo pipefail
if [ $( ./corso --version | grep 'Corso version:' | wc -l) -ne 1 ]
then
@ -364,4 +364,46 @@ jobs:
path: src/testlog/*
if-no-files-found: error
retention-days: 14
# run the tests
- name: SHA info
id: sha-info
if: failure()
run: |
echo ${GITHUB_REF#refs/heads/}-${GITHUB_SHA}
echo SHA=${GITHUB_REF#refs/heads/}-${GITHUB_SHA} >> $GITHUB_OUTPUT
echo RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_OUTPUT
echo COMMIT_URL=${{ github.server_url }}/${{ github.repository }}/commit/${GITHUB_SHA} >> $GITHUB_OUTPUT
- name: Send Github Action failure to Slack
id: slack-notification
if: failure()
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
"text": "GitHub Action build result: ${{ job.status }} on SHA: ${{ steps.sha-info.outputs.SHA }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Failure in Sanity Test"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<${{ steps.sha-info.outputs.RUN_URL }}|Check logs> for <${{ steps.sha-info.outputs.COMMIT_URL }}|${{ steps.sha-info.outputs.SHA }}>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK