From e5e06761c33fcdf11de32091d90cb1eacd12e10b Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 17 Sep 2024 10:54:07 +0100 Subject: [PATCH] CI: Add Slack alert to automatically triggered workflows Alert on failures for automatically triggered workflows. For manually triggered workflows we rely on GitHub emails to the individual that triggered the workflow. See the "Workflow builder" approach in https://github.com/slackapi/slack-github-action/. --- .../workflows/stackhpc-build-kayobe-image.yml | 22 +++++++++++++++++++ .github/workflows/stackhpc-ci-cleanup.yml | 21 ++++++++++++++++++ .github/workflows/stackhpc-promote.yml | 22 +++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/.github/workflows/stackhpc-build-kayobe-image.yml b/.github/workflows/stackhpc-build-kayobe-image.yml index c45e0456b..cbbac9f71 100644 --- a/.github/workflows/stackhpc-build-kayobe-image.yml +++ b/.github/workflows/stackhpc-build-kayobe-image.yml @@ -98,3 +98,25 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + - name: Send message to Slack via Workflow Builder + uses: slackapi/slack-github-action@v1.26.0 + with: + payload: | + { + "channel-id": "${{ env.SLACK_CHANNEL_ID }}", + "inputs": "${{ env.INPUTS }}", + "message": "${{ env.MESSAGE }}", + "results-url": "${{ env.RESULTS_URL }}", + "workflow-url": "${{ env.WORKFLOW_URL }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + # #release-train-alerts + SLACK_CHANNEL_ID: C03B28HRP53 + INPUTS: >- + branch: ${{ github.ref_name }} + MESSAGE: "SKC Build Kayobe Image workflow failed :sob:" + RESULTS_URL: "N/A" + WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + if: failure() && github.event_name == 'push' diff --git a/.github/workflows/stackhpc-ci-cleanup.yml b/.github/workflows/stackhpc-ci-cleanup.yml index ed9ec327c..a14b2970c 100644 --- a/.github/workflows/stackhpc-ci-cleanup.yml +++ b/.github/workflows/stackhpc-ci-cleanup.yml @@ -75,3 +75,24 @@ jobs: OS_CLOUD: openstack OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} + + - name: Send message to Slack via Workflow Builder + uses: slackapi/slack-github-action@v1.26.0 + with: + payload: | + { + "channel-id": "${{ env.SLACK_CHANNEL_ID }}", + "inputs": "${{ env.INPUTS }}", + "message": "${{ env.MESSAGE }}", + "results-url": "${{ env.RESULTS_URL }}", + "workflow-url": "${{ env.WORKFLOW_URL }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + # #release-train-alerts + SLACK_CHANNEL_ID: C03B28HRP53 + INPUTS: "N/A" + MESSAGE: "SKC CI Cleanup workflow failed :sob:" + RESULTS_URL: "N/A" + WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + if: failure() diff --git a/.github/workflows/stackhpc-promote.yml b/.github/workflows/stackhpc-promote.yml index 61385c819..386d4d405 100644 --- a/.github/workflows/stackhpc-promote.yml +++ b/.github/workflows/stackhpc-promote.yml @@ -27,3 +27,25 @@ jobs: - name: Display link to package repository promotion workflows run: | echo "::notice Package repository promote workflow: https://github.com/stackhpc/stackhpc-release-train/actions/workflows/package-promote.yml" + + - name: Send message to Slack via Workflow Builder + uses: slackapi/slack-github-action@v1.26.0 + with: + payload: | + { + "channel-id": "${{ env.SLACK_CHANNEL_ID }}", + "inputs": "${{ env.INPUTS }}", + "message": "${{ env.MESSAGE }}", + "results-url": "${{ env.RESULTS_URL }}", + "workflow-url": "${{ env.WORKFLOW_URL }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + # #release-train-alerts + SLACK_CHANNEL_ID: C03B28HRP53 + INPUTS: >- + branch: ${{ github.ref_name }} + MESSAGE: "SKC promote workflow failed :sob:" + RESULTS_URL: "N/A" + WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + if: failure()