Skip to content

Commit

Permalink
Add notify-on-failure action
Browse files Browse the repository at this point in the history
Adds a composite action that can be used to send Slack notifications
for failed GitHub Action workflows. Intended to be used with the
pathogen-repo-build workflow, but I've made it a separate composite
action because it may be useful for monitoring GitHub Actions that are
not running Nextstrain builds.
  • Loading branch information
joverlee521 committed Aug 3, 2023
1 parent 261c64f commit 45592e8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Invoked by our GitHub Actions workflows, including the reusable workflows below.
- [Setup debugger](actions/setup-debugger/action.yaml) for interactive debugging of workflow jobs
([README](actions/setup-debugger/README.md))
- [Workflow context](actions/workflow-context/action.yaml)
- [Notify on failure](actions/notify-on-failure/action.yaml)

See also GitHub's [documentation on creating custom actions](https://docs.github.com/en/actions/creating-actions/about-custom-actions).

Expand Down
31 changes: 31 additions & 0 deletions actions/notify-on-failure/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Notify Slack on failure
description: >-
Sends Slack notification with link to a GitHub Action workflow run that failed.
Intended to be used for automated pathogen build workflows to ensure that the
entire team is notified of a GitHub Action failure and not just the GitHub
user who originally launched and/or scheduled the workflow.
Requires two environment variables to be set in the workflow:
- SLACK_TOKEN
- SLACK_CHANNELS
SLACK_TOKEN is the OAuth token for the Slack app that has permissions to send messages.
SLACK_CHANNELS is the name or channel id for the intended Slack channel.
runs:
using: composite
steps:
- uses: actions/checkout@v3
with:
repository: nextstrain/ingest
path: nextstrain-ingest
sparse-checkout: |
notify-on-job-fail
- name: Notify job failure
shell: bash
run: ./nextstrain-ingest/notify-on-job-fail "$WORKFLOW_NAME" "$JOB_REPO"
env:
WORKFLOW_NAME: ${{ github.workflow }}
JOB_REPO: ${{ github.repository }}

0 comments on commit 45592e8

Please sign in to comment.