Skip to content

Commit 080598a

Browse files
authored
Merge pull request #7 from rubyatscale/jms/doc-step-and-notify-on-fail
add step to shared ci / cd workflows to notify on failure on main branch
2 parents 58c39fc + e3e4fb0 commit 080598a

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

.github/workflows/cd.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@ jobs:
2121
if: ${{ steps.tag-and-push-gem.outputs.new_version == 'true' }}
2222
env:
2323
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
notify_on_failure:
25+
runs-on: ubuntu-latest
26+
needs: [deploy]
27+
if: ${{ failure() && github.ref == 'refs/heads/main' }}
28+
env:
29+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
30+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
31+
steps:
32+
- uses: slackapi/slack-github-action@v1.25.0
33+
with:
34+
payload: |
35+
{
36+
"text": "${{ github.repository }}/${{ github.ref }}: FAILED\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
37+
}

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,17 @@ jobs:
4949
ruby-version: 3.3
5050
- name: Run style checks
5151
run: bundle exec rubocop
52+
notify_on_failure:
53+
runs-on: ubuntu-latest
54+
needs: [rspec, static_type_check, rubocop]
55+
if: ${{ failure() && github.ref == 'refs/heads/main' }}
56+
env:
57+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
58+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
59+
steps:
60+
- uses: slackapi/slack-github-action@v1.25.0
61+
with:
62+
payload: |
63+
{
64+
"text": "${{ github.repository }}/${{ github.ref }}: FAILED\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
65+
}

0 commit comments

Comments
 (0)