Skip to content

Commit

Permalink
Send slack notification on failed GHA jobs (#346)
Browse files Browse the repository at this point in the history
* Add slack notification to postmerge task failures

* test if conditional

* remove debug messages
  • Loading branch information
nv-alaiacano authored May 16, 2023
1 parent 2b1b90b commit 14cc993
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-pypi:
name: Build PyPI Package
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/postmerge-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,21 @@ jobs:
with:
name: pr
path: pr/

# If failures occur, notify in slack.
- name: Notify Failure in Slack
id: slack
uses: slackapi/[email protected]
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"message": "GitHub Action job failure on github.ref `${{ github.ref }}`",
"pull_request": "${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"workflow": "${{ github.workflow }}",
"logs_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
env:
PR_NUMBER: ${{ github.event.number }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
18 changes: 18 additions & 0 deletions .github/workflows/postmerge-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ jobs:
branch=${raw/origin\/}
fi
cd ${{ github.workspace }}; tox -e test-gpu-postmerge -- $branch
# If failures occur, notify in slack.
- name: Notify Failure in Slack
id: slack
uses: slackapi/[email protected]
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"message": "GitHub Action job failure on github.ref `${{ github.ref }}`",
"pull_request": "${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"workflow": "${{ github.workflow }}",
"logs_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
env:
PR_NUMBER: ${{ github.event.number }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 comments on commit 14cc993

Please sign in to comment.