From 0195ac087b55eef3d5b9968fc432419dd1c370f6 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Wed, 13 Sep 2023 14:39:14 +0100 Subject: [PATCH] Post to Slack when `ci.yml` fails on `main` --- _shared/project/.github/workflows/slack.yml | 18 ++++++++++++++++++ .../.github/workflows/slack.yml | 1 + .../.github/workflows/slack.yml | 1 + .../.github/workflows/slack.yml | 1 + 4 files changed, 21 insertions(+) create mode 100644 _shared/project/.github/workflows/slack.yml create mode 120000 pyapp/{{ cookiecutter.slug }}/.github/workflows/slack.yml create mode 120000 pypackage/{{ cookiecutter.slug }}/.github/workflows/slack.yml create mode 120000 pyramid-app/{{ cookiecutter.slug }}/.github/workflows/slack.yml diff --git a/_shared/project/.github/workflows/slack.yml b/_shared/project/.github/workflows/slack.yml new file mode 100644 index 0000000..243fc21 --- /dev/null +++ b/_shared/project/.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: {% raw %}${{ github.event.workflow_run.conclusion == 'failure' }}{% endraw %} + 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:* `{% raw %}${{ github.event.repository.full_name }}{% endraw %}` ({% raw %}${{ github.event.repository.html_url }}{% endraw %})\n*Workflow:* {% raw %}${{ github.event.workflow.name }}{% endraw %} ({% raw %}${{ github.event.workflow.html_url }}{% endraw %})\n*Branch:* `{% raw %}${{ github.event.workflow_run.head_branch }}{% endraw %}`\n*Commit:* `{% raw %}${{ github.event.workflow_run.head_commit.id }}{% endraw %}`\n*Run:* {% raw %}${{ github.event.workflow_run.html_url }}{% endraw %}\n*Conclusion:* {% raw %}${{ github.event.workflow_run.conclusion }}{% endraw %}" + env: + SLACK_BOT_TOKEN: {% raw %}${{ secrets.SLACK_BOT_TOKEN }}{% endraw %} diff --git a/pyapp/{{ cookiecutter.slug }}/.github/workflows/slack.yml b/pyapp/{{ cookiecutter.slug }}/.github/workflows/slack.yml new file mode 120000 index 0000000..9fa4735 --- /dev/null +++ b/pyapp/{{ cookiecutter.slug }}/.github/workflows/slack.yml @@ -0,0 +1 @@ +../../../../_shared/project/.github/workflows/slack.yml \ No newline at end of file diff --git a/pypackage/{{ cookiecutter.slug }}/.github/workflows/slack.yml b/pypackage/{{ cookiecutter.slug }}/.github/workflows/slack.yml new file mode 120000 index 0000000..9fa4735 --- /dev/null +++ b/pypackage/{{ cookiecutter.slug }}/.github/workflows/slack.yml @@ -0,0 +1 @@ +../../../../_shared/project/.github/workflows/slack.yml \ No newline at end of file diff --git a/pyramid-app/{{ cookiecutter.slug }}/.github/workflows/slack.yml b/pyramid-app/{{ cookiecutter.slug }}/.github/workflows/slack.yml new file mode 120000 index 0000000..9fa4735 --- /dev/null +++ b/pyramid-app/{{ cookiecutter.slug }}/.github/workflows/slack.yml @@ -0,0 +1 @@ +../../../../_shared/project/.github/workflows/slack.yml \ No newline at end of file