From 2ab644dc0c5d76a82351bc84c042ebd9c851523f Mon Sep 17 00:00:00 2001 From: kdivya153 <121901963+kdivya153@users.noreply.github.com> Date: Sat, 12 Oct 2024 22:45:23 -0400 Subject: [PATCH] Update check-pr.yml --- .github/workflows/check-pr.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index f8d02b78..01ad2d9e 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -80,3 +80,27 @@ jobs: sleep 120 fi done + + notify-slack-on-failure: + needs: wait-for-repo2 + if: failure() + runs-on: ubuntu-latest + steps: + - name: Send Slack notification + run: | + # Determine the branch name based on the event type + if [ "$EVENT_NAME" == "repository_dispatch" ]; then + BRANCH_NAME=$OPENRPC_PR_BRANCH + elif [ "$EVENT_NAME" == "pull_request" ]; then + BRANCH_NAME=$PR_HEAD_REF + elif [ "$EVENT_NAME" == "push" ]; then + BRANCH_NAME=${GITHUB_REF#refs/heads/} # Extract branch name from GITHUB_REF for push events + else + BRANCH_NAME="unknown" + fi + + # Send the Slack notification with the branch name + curl -X POST -H 'Content-type: application/json' \ + --data '{"text": "Failed to generate SDK artifact with the latest changes in the Branch: '$BRANCH_NAME'."}' \ + ${{ secrets.SLACK_WEBHOOK_URL }} +