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 }} +