From 7327ab75c95743cda831f0a18c89f6032d8a9d2f Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Thu, 14 Oct 2021 13:05:49 -0400 Subject: [PATCH] Add Slack alerts for Build workflow failures (#1108) --- .github/workflows/build.yml | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 963863bb..5e7f7cda 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1000,3 +1000,65 @@ jobs: name: Bitwarden-${{ env._PACKAGE_VERSION }}-masdev-universal.zip path: ./dist/mas-universal/Bitwarden-${{ env._PACKAGE_VERSION }}-masdev-universal.zip if-no-files-found: error + + + check-failures: + name: Check for failures + if: always() + runs-on: ubuntu-20.04 + needs: + - cloc + - setup + - linux + - windows + - macos-build + - macos-package-github + - macos-package-mas + steps: + - name: Check if any job failed + env: + CLOC_STATUS: ${{ needs.cloc.result }} + SETUP_STATUS: ${{ needs.setup.result }} + LINUX_STATUS: ${{ needs.linux.result }} + WINDOWS_STATUS: ${{ needs.windows.result }} + MACOS_BUILD_STATUS: ${{ needs.macos-build.result }} + MACOS_PKG_GITHUB_STATUS: ${{ needs.macos-package-github.result }} + MACOS_PKG_MAS_STATUS: ${{ needs.macos-package-mas.result }} + run: | + if [ "$CLOC_STATUS" = "failure" ]; then + exit 1 + elif [ "$SETUP_STATUS" = "failure" ]; then + exit 1 + elif [ "$LINUX_STATUS" = "failure" ]; then + exit 1 + elif [ "$WINDOWS_STATUS" = "failure" ]; then + exit 1 + elif [ "$MACOS_BUILD_STATUS" = "failure" ]; then + exit 1 + elif [ "$MACOS_PKG_GITHUB_STATUS" = "failure" ]; then + exit 1 + elif [ "$MACOS_PKG_MAS_STATUS" = "failure" ]; then + exit 1 + fi + + - name: Login to Azure - Prod Subscription + uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a + if: failure() + with: + creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403 + if: failure() + with: + keyvault: "bitwarden-prod-kv" + secrets: "devops-alerts-slack-webhook-url" + + - name: Notify Slack on failure + uses: act10ns/slack@e4e71685b9b239384b0f676a63c32367f59c2522 # v1.2.2 + if: failure() + env: + SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }} + with: + status: ${{ job.status }}