Skip to content

Commit

Permalink
Add 'notify on failure' workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchnielsen committed Feb 3, 2025
1 parent d07993a commit f788c67
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/notify-on-failure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Notify on Failure

"on":
workflow_run:
workflows:
- Update mise tool versions
types: [completed]

permissions: {}

jobs:
notify:
name: Notify on Failure
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
permissions:
actions: read
contents: read
steps:
- name: Format date
run: |
formatted_date=$(date -d "${{ github.event.workflow_run.run_started_at }}" "+%b %d at %I:%M %p")
echo "FORMATTED_DATE=$formatted_date" >> $GITHUB_ENV
- name: Send Slack notification
uses: 8398a7/action-slack@v3
with:
status: custom
# https://api.slack.com/reference/messaging/attachments
custom_payload: |
{
attachments: [{
pretext: ':x: Workflow triggered by ${{ github.actor }} failed',
title: '${{ github.event.workflow_run.display_title }} #${{github.event.workflow_run.run_number}}',
title_link: '${{ github.event.workflow_run.html_url }}',
footer: '${{ github.repository }} | ${{ env.FORMATTED_DATE }} UTC',
footer_icon: 'https://slack-imgs.com/?c=1&o1=wi32.he32.si&url=https%3A%2F%2Fslack.github.com%2Fstatic%2Fimg%2Ffavicon-neutral.png',
color: 'danger',
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_GHA_JOB_STATUS }}

0 comments on commit f788c67

Please sign in to comment.