Skip to content

Commit

Permalink
Add Github action workflow to notify on main jobs failures (#690)
Browse files Browse the repository at this point in the history
**Context:**
It is useful to receive notifications whenever a github action workflow
running on mail fails. Github has a slack integration that can be
configured, but that sends notification for every job in any
state(started, cancelled, failed, succeeded). There is an [open
issue](integrations/slack#1563) that hasn't
been solved for 2 years.
Because of this, a manual job that triggers based on failures of
selected job on main is a better approach, and it won't need to add the
notification on each single job.

**Description of the Change:**
A new workflow is added that will send notification to a slack
channel(specified in the webhook configuration in the slack settings).

**Benefits:**
Get notification when specified jobs fails on main

**Possible Drawbacks:**
None

**Related GitHub Issues:**
None
  • Loading branch information
smokingroosters authored Apr 26, 2024
1 parent f85e9dc commit 8073e29
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/notify-failed-jobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Notify on main failures
on:
workflow_run:
branches:
- main
types:
- completed
workflows:
- Build Catalyst Wheel on Linux (x86_64)
- Build Catalyst Wheel on macOS (arm64)
- Build Catalyst Wheel on macOS (x86_64)

jobs:
on-failure:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out'
steps:
- uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ github.event.workflow_run.conclusion }}
notification_title: " ${{github.event.workflow_run.name}} - ${{github.event.workflow_run.conclusion}} on ${{github.event.workflow_run.head_branch}} - <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View Failure>"
message_format: ":fire: *${{github.event.workflow_run.name}}* ${{github.event.workflow_run.conclusion}} in <${{github.server_url}}/${{github.repository}}/${{github.event.workflow_run.head_branch}}|${{github.repository}}>"
footer: "Linked Repo <${{github.server_url}}/${{github.repository}}|${{github.repository}}> | <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View Failure>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK_URL }}

0 comments on commit 8073e29

Please sign in to comment.