From 6e2a7bf43f1214da34fb6de9e22790d4240166e1 Mon Sep 17 00:00:00 2001 From: mrjoelkamp Date: Tue, 23 Jul 2024 10:11:47 -0500 Subject: [PATCH] feat: add action failure notifications --- .github/workflows/mirror.yml | 14 ++++++++++++++ .github/workflows/online-sign.yml | 18 ++++++++++++++++-- .github/workflows/publish.yml | 14 ++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index ef8b4e4..963945f 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -34,3 +34,17 @@ jobs: destination: docker://docker/tuf-targets tuf-root: prod flags: "-f" + failure-notification: + runs-on: ubuntu-latest + needs: [mirror] + if: ${{ always() && contains(needs.*.result, 'failure') }} + steps: + - name: Slack Notification + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_COLOR: failure + MSG_MINIMAL: true + SLACK_TITLE: "${{ github.workflow }} - Failure" + SLACK_MESSAGE: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + SLACK_FOOTER: "triggered by ${{ github.repository }}" diff --git a/.github/workflows/online-sign.yml b/.github/workflows/online-sign.yml index a0a9088..a0b2f2c 100644 --- a/.github/workflows/online-sign.yml +++ b/.github/workflows/online-sign.yml @@ -4,11 +4,11 @@ permissions: {} on: schedule: - - cron: '17 1,7,13,19 * * *' + - cron: "17 1,7,13,19 * * *" push: branches: [main] paths: - ['metadata/**', '!metadata/timestamp.json', '!metadata/snapshot.json'] + ["metadata/**", "!metadata/timestamp.json", "!metadata/snapshot.json"] workflow_dispatch: jobs: @@ -51,3 +51,17 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} success: ${{ !contains(needs.*.result, 'failure') }} + failure-notification: + runs-on: ubuntu-latest + needs: [online-sign, update-issue] + if: ${{ always() && contains(needs.*.result, 'failure') }} + steps: + - name: Slack Notification + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_COLOR: failure + MSG_MINIMAL: true + SLACK_TITLE: "${{ github.workflow }} - Failure" + SLACK_MESSAGE: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + SLACK_FOOTER: "triggered by ${{ github.repository }}" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 494b6e8..aa0c519 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -62,3 +62,17 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} success: ${{ !contains(needs.*.result, 'failure') }} + failure-notification: + runs-on: ubuntu-latest + needs: [build, deploy-to-pages, test-deployed-repository, update-issue] + if: ${{ always() && contains(needs.*.result, 'failure') }} + steps: + - name: Slack Notification + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_COLOR: failure + MSG_MINIMAL: true + SLACK_TITLE: "${{ github.workflow }} - Failure" + SLACK_MESSAGE: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + SLACK_FOOTER: "triggered by ${{ github.repository }}"