From db11e5dc351abba41bd017e4252cb40aea8feaef Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Mon, 7 Oct 2024 18:31:15 -0400 Subject: [PATCH] Add failure check --- .github/workflows/repository-management.yml | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.github/workflows/repository-management.yml b/.github/workflows/repository-management.yml index 9cfd07f2aaf0..2577a0baabe0 100644 --- a/.github/workflows/repository-management.yml +++ b/.github/workflows/repository-management.yml @@ -232,3 +232,50 @@ jobs: needs: cherry_pick uses: ./.github/workflows/_move_finalization_db_scripts.yml secrets: inherit + + + check-failures: + name: Check for failures + if: always() + runs-on: ubuntu-22.04 + needs: + - cut_branch + - bump_version + - cherry_pick + - move_future_db_scripts + steps: + - name: Check if any job failed + if: | + (github.ref == 'refs/heads/main' + || github.ref == 'refs/heads/rc' + || github.ref == 'refs/heads/hotfix-rc') + && contains(needs.*.result, 'failure') + run: exit 1 + + - name: Clean up new branch + if: failure() + env: + CUT_BRANCH: ${{ inputs.branch_to_cut }} + run: git push -d origin $CUT_BRANCH + + - name: Log in to Azure - CI subscription + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 + if: failure() + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + if: failure() + with: + keyvault: "bitwarden-ci" + secrets: "devops-alerts-slack-webhook-url" + + - name: Notify Slack on failure + uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0 + if: failure() + env: + SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }} + with: + status: ${{ job.status }}