From ceb3735ebe8d8760bd4ed70ac35cd59477b0407f Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Wed, 13 Sep 2023 14:38:10 +0100 Subject: [PATCH] Post to Slack when `ci.yml` fails on `main` --- .github/workflows/slack.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/slack.yml diff --git a/.github/workflows/slack.yml b/.github/workflows/slack.yml new file mode 100644 index 00000000..3198a29b --- /dev/null +++ b/.github/workflows/slack.yml @@ -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/slack-github-action@v1.24.0 + 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 }}