From 06b8942e42b9c1648ed7f3739ac7a157048c7403 Mon Sep 17 00:00:00 2001 From: neha-Gupta1 Date: Thu, 20 Apr 2023 08:02:36 +0530 Subject: [PATCH] notify on cleanup failure --- .github/workflows/ci_test_cleanup.yml | 42 +++++++++++++++++++++++++++ .github/workflows/sanity-test.yaml | 1 - 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_test_cleanup.yml b/.github/workflows/ci_test_cleanup.yml index c82fc343f..e3fd4edf9 100644 --- a/.github/workflows/ci_test_cleanup.yml +++ b/.github/workflows/ci_test_cleanup.yml @@ -67,3 +67,45 @@ jobs: azure-tenant-id: ${{ secrets.TENANT_ID }} m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }} m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }} + + # run the tests + - name: SHA info + id: sha-info + if: failure() + run: | + 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 Test-Site-Data-Cleanup" + } + }, + { + "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 \ No newline at end of file diff --git a/.github/workflows/sanity-test.yaml b/.github/workflows/sanity-test.yaml index 59f7190fb..93f4b7211 100644 --- a/.github/workflows/sanity-test.yaml +++ b/.github/workflows/sanity-test.yaml @@ -370,7 +370,6 @@ jobs: 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