From 72fd683609db3dbb46ab9cc4e698aac9104f3a75 Mon Sep 17 00:00:00 2001 From: Manali-Jain-Squareops Date: Tue, 8 Aug 2023 09:35:06 +0530 Subject: [PATCH] slack alerts on success/failure --- .github/workflows/nightly-current-sprint.yaml | 35 +++++++++++++++++-- .github/workflows/nightly-staging.yml | 35 +++++++++++++++++-- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly-current-sprint.yaml b/.github/workflows/nightly-current-sprint.yaml index 4b8ad8fe3f..5a0679fbbf 100644 --- a/.github/workflows/nightly-current-sprint.yaml +++ b/.github/workflows/nightly-current-sprint.yaml @@ -60,7 +60,38 @@ jobs: value: ${{ secrets.SEND_SLACK_NOTIFICATION }} default: false + notify_slack_on_failure: + runs-on: [self-hosted, arc-runner] + needs: [system-tests] + if: always() && (needs.system-tests.result == 'failure') + steps: + - name: "Notify Slack" + run: | + payload='{ + "text": "'" 0Chain Nightly Tests - Current Sprint FAILED on $(echo ${GITHUB_REF#refs/heads/})!.\n View the test results on Github: https://github.com/0chain/system_test/actions/runs/${{ github.run_id }}"'", + "attachments": [ + { + "text": "0Chain Nightly Tests - Current Sprint FAILED ⚠️", + "color": "#ff0000" + } + ] + }' + curl -X POST -H 'Content-type: application/json' --data "${payload}" ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }} + + notify_slack_on_success: + runs-on: [self-hosted, arc-runner] + needs: [system-tests] + if: always() && (needs.system-tests.result == 'success') + steps: - name: "Notify Slack" - if: failure() && steps.send-slack-notification.outputs.value == 'true' run: | - curl -X POST -H 'Content-type: application/json' --data '{"text":" 0Chain nightly run failed against current sprint. View the test results on Github: https://github.com/0chain/system_test/actions/runs/${{ github.run_id }}"}' ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }} + payload='{ + "text": "'" 0Chain Nightly Tests - Current Sprint PASSING on $(echo ${GITHUB_REF#refs/heads/})!.\n View the test results on Github: https://github.com/0chain/system_test/actions/runs/${{ github.run_id }}"'", + "attachments": [ + { + "text": "0Chain Nightly Tests - Current Sprint PASSED ✅", + "color": "#22bb33" + } + ] + }' + curl -X POST -H 'Content-type: application/json' --data "${payload}" ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }} \ No newline at end of file diff --git a/.github/workflows/nightly-staging.yml b/.github/workflows/nightly-staging.yml index 9301fc5b31..bdef1e79f8 100644 --- a/.github/workflows/nightly-staging.yml +++ b/.github/workflows/nightly-staging.yml @@ -59,7 +59,38 @@ jobs: value: ${{ secrets.SEND_SLACK_NOTIFICATION }} default: false + notify_slack_on_failure: + runs-on: [self-hosted, arc-runner] + needs: [system-tests] + if: always() && (needs.system-tests.result == 'failure') + steps: + - name: "Notify Slack" + run: | + payload='{ + "text": "'" 0Chain Nightly Tests - Staging FAILED on $(echo ${GITHUB_REF#refs/heads/})!.\n View the test results on Github: https://github.com/0chain/system_test/actions/runs/${{ github.run_id }}"'", + "attachments": [ + { + "text": "0Chain Nightly Tests - Staging FAILED ⚠️", + "color": "#ff0000" + } + ] + }' + curl -X POST -H 'Content-type: application/json' --data "${payload}" ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }} + + notify_slack_on_success: + runs-on: [self-hosted, arc-runner] + needs: [system-tests] + if: always() && (needs.system-tests.result == 'success') + steps: - name: "Notify Slack" - if: failure() && steps.send-slack-notification.outputs.value == 'true' run: | - curl -X POST -H 'Content-type: application/json' --data '{"text":" 0Chain nightly run failed against staging. View the test results on Github: https://github.com/0chain/system_test/actions/runs/${{ github.run_id }}"}' ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }} + payload='{ + "text": "'" 0Chain Nightly Tests - Staging PASSING on $(echo ${GITHUB_REF#refs/heads/})!.\n View the test results on Github: https://github.com/0chain/system_test/actions/runs/${{ github.run_id }}"'", + "attachments": [ + { + "text": "0Chain Nightly Tests - Staging PASSED ✅", + "color": "#22bb33" + } + ] + }' + curl -X POST -H 'Content-type: application/json' --data "${payload}" ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }} \ No newline at end of file