Sends a slack alert when a job fails
The alert contains the name of the repo, the workflow and the GitHub user who triggered the workflow.
Anyone who triggers workflows should add their GitHub username as a keyword in Slack.
- Add any jobs that you want to monitor.
- Add a new job.
- It must
needs
any jobs you want to monitor. Needs can accept an array. - Set
if: ${{ failure() }}
on the new job. - Make the new job
uses: iStreamPlanet/github-actions/.github/workflows/fail-alert.yml@main
- fail-alert has no inputs, but does require a
secrets.slack_webhook
for whichever slack channel you want to message.
Here's an example workflow
name: Project X
on:
push
jobs:
build:
runs-on: ubuntu-latest
steps
- name: Something Fails!
run: |
exit 1
notify:
needs: build
if: ${{ failure() }}
uses: iStreamPlanet/github-actions/.github/workflows/fail-alert.yml@main
secrets:
slack_webhook: ${{ secrets.DEPLOYMENTS_SLACK_WEBHOOK }}
- Get an org-wide webhook and call it from within fail-alert. Users wouldn't need to have one.
- Accept optional inputs to override values from github. E.G. workflow name, contact etc...
- Better slack message formatting with Block Kit.
- Somehow map gh users to slack name and do a real @
- Make an actual slack app that looks it up on a table or something
- Have users put their slack @handle in gh profile and look that up somehow?