From ce3f204a9cc3e9e4edc6f37572827802060ed1bc Mon Sep 17 00:00:00 2001 From: neha-Gupta1 Date: Thu, 18 May 2023 17:50:52 +0530 Subject: [PATCH] move notification of failure to purge script --- .github/actions/purge-m365-data/action.yml | 38 ++++++++++++++++++++ .github/workflows/ci_test_cleanup.yml | 42 ---------------------- 2 files changed, 38 insertions(+), 42 deletions(-) diff --git a/.github/actions/purge-m365-data/action.yml b/.github/actions/purge-m365-data/action.yml index d7681e55b..5e4070f86 100644 --- a/.github/actions/purge-m365-data/action.yml +++ b/.github/actions/purge-m365-data/action.yml @@ -91,3 +91,41 @@ runs: M365_TENANT_ADMIN_PASSWORD: ${{ inputs.m365-admin-password }} run: | ./onedrivePurge.ps1 -Site ${{ inputs.site }} -LibraryNameList "${{ inputs.libraries }}".split(",") -FolderPrefixPurgeList ${{ inputs.folder-prefix }} -PurgeBeforeTimestamp ${{ inputs.older-than }} + + ################################################################################################################ + # Notifications on failure + # + + - name: SHA info + id: sha-info + shell: pwsh + working-directory: ./src/cmd/purge/scripts + 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 + + - name: Send Github Action failure to Slack + id: slack-notification + shell: pwsh + working-directory: ./src/cmd/purge/scripts + 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": "section", + "text": { + "type": "mrkdwn", + "text": "[FAILED] Purge M365 User Data :: <${{ steps.sha-info.outputs.RUN_URL }}|[Logs]> <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|[Base]>" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file diff --git a/.github/workflows/ci_test_cleanup.yml b/.github/workflows/ci_test_cleanup.yml index 1c4591e29..65e678e4b 100644 --- a/.github/workflows/ci_test_cleanup.yml +++ b/.github/workflows/ci_test_cleanup.yml @@ -68,45 +68,3 @@ 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