From cade65423ce22155be2835a1bb8803a0956a8056 Mon Sep 17 00:00:00 2001 From: hc-github-team-secure-vault-core <82990506+hc-github-team-secure-vault-core@users.noreply.github.com> Date: Fri, 21 Jul 2023 08:50:26 -0400 Subject: [PATCH] backport of commit 02f43ecbc26ec79790f30826f49f97cecda987eb (#21587) (#21996) * VAULT-17590 Add failure notifications for OSS builds * VAULT-17590 Incur build failure for testing purposes * VAULT-17590 head_ref for testing * VAULT-17590 rework to rely on completed status checks * VAULT-17590 Use slackapi/slack-github-action * VAULT-17590 Remember dollar sign * VAULT-17590 finalize PR * VAULT-17590 add extra empty line * Update .github/workflows/build.yml * Update .github/workflows/ci.yml * VAULT-17590 fix typo * VAULT-17590 ent workflow * VAULT-17590 typo --------- Co-authored-by: Violet Hynes Co-authored-by: Kuba Wieczorek --- .github/workflows/build.yml | 55 ++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ebffad9b..9b78cb757 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -326,4 +326,57 @@ jobs: - test-docker-k8s steps: - run: | - tr -d '\n' <<< '${{ toJSON(needs.*.result) }}' | grep -q -v -E '(failure|cancelled)' \ No newline at end of file + tr -d '\n' <<< '${{ toJSON(needs.*.result) }}' | grep -q -v -E '(failure|cancelled)' + + notify-completed-successfully-failures-oss: + if: ${{ always() && github.repository == 'hashicorp/vault' && needs.completed-successfully.result == 'failure' && (github.ref_name == 'main' || startsWith(github.ref_name, 'release/')) }} + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + needs: + - completed-successfully + steps: + - name: send-notification + uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 + # We intentionally aren't using the following here since it's from an internal repo + # uses: hashicorp/cloud-gha-slack-notifier@730a033037b8e603adf99ebd3085f0fdfe75e2f4 #v1 + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + with: + channel-id: "C05AABYEA9Y" # sent to #feed-vault-ci-official + payload: | + {"text":"OSS build failures on ${{ github.ref_name }}","blocks":[{"type":"header","text":{"type":"plain_text","text":":rotating_light: OSS build failures :rotating_light:","emoji":true}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":"build(s) failed on ${{ github.ref_name }}"},"accessory":{"type":"button","text":{"type":"plain_text","text":"View Failing Workflow","emoji":true},"url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}}]} + + notify-completed-successfully-failures-ent: + if: ${{ always() && github.repository == 'hashicorp/vault-enterprise' && needs.completed-successfully.result == 'failure' && (github.ref_name == 'main' || startsWith(github.ref_name, 'release/')) }} + runs-on: ['self-hosted', 'linux', 'small'] + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + needs: + - completed-successfully + steps: + - id: vault-auth + name: Vault Authenticate + run: vault-auth + - id: secrets + name: Fetch Vault Secrets + uses: hashicorp/vault-action@130d1f5f4fe645bb6c83e4225c04d64cfb62de6e + with: + url: ${{ steps.vault-auth.outputs.addr }} + caCertificate: ${{ steps.vault-auth.outputs.ca_certificate }} + token: ${{ steps.vault-auth.outputs.token }} + secrets: | + kv/data/github/${{ github.repository }}/github_actions_notifications_bot token | SLACK_BOT_TOKEN; + - name: send-notification + uses: hashicorp/cloud-gha-slack-notifier@730a033037b8e603adf99ebd3085f0fdfe75e2f4 #v1 + with: + channel-id: "C05AABYEA9Y" # sent to #feed-vault-ci-official + slack-bot-token: ${{ steps.secrets.outputs.SLACK_BOT_TOKEN }} + payload: | + {"text":"Enterprise build failures on ${{ github.ref_name }}","blocks":[{"type":"header","text":{"type":"plain_text","text":":rotating_light: Enterprise build failures :rotating_light:","emoji":true}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":"build(s) failed on ${{ github.ref_name }}"},"accessory":{"type":"button","text":{"type":"plain_text","text":"View Failing Workflow","emoji":true},"url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}}]}