-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d07993a
commit f788c67
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |