Skip to content

Commit

Permalink
Post to Slack when ci.yml fails on main
Browse files Browse the repository at this point in the history
  • Loading branch information
seanh committed Sep 19, 2023
1 parent 1de3219 commit 384a735
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous integration
name: CI

on:
pull_request:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/slack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Slack
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
jobs:
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Post to Slack
uses: slackapi/[email protected]
with:
channel-id: 'C4K6M7P5E'
slack-message: "A workflow run failed\n*Repo:* `${{ github.event.repository.full_name }}` (${{ github.event.repository.html_url }})\n*Workflow:* ${{ github.event.workflow.name }} (${{ github.event.workflow.html_url }})\n*Branch:* `${{ github.event.workflow_run.head_branch }}`\n*Commit:* `${{ github.event.workflow_run.head_commit.id }}`\n*Run:* ${{ github.event.workflow_run.html_url }}\n*Conclusion:* ${{ github.event.workflow_run.conclusion }}"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 comments on commit 384a735

Please sign in to comment.