Skip to content

Commit

Permalink
CI: Add Slack alert to automatically triggered workflows
Browse files Browse the repository at this point in the history
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/.
  • Loading branch information
markgoddard committed Sep 17, 2024
1 parent 7d98067 commit e5e0676
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/stackhpc-build-kayobe-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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'
21 changes: 21 additions & 0 deletions .github/workflows/stackhpc-ci-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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()
22 changes: 22 additions & 0 deletions .github/workflows/stackhpc-promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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()

0 comments on commit e5e0676

Please sign in to comment.