Skip to content

Commit 6b84283

Browse files
authored
Add slack notification on build failure (#136)
commit-id:960efd4f
1 parent 8b0ac40 commit 6b84283

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

.github/workflows/cross_version_test.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,69 @@ jobs:
6565
PYBATFISH_PYPI_TOKEN: ${{ secrets.PYBATFISH_PYPI_TOKEN }}
6666
BATFISH_DOCKER_LOGIN_TOKEN: ${{ secrets.BATFISH_DOCKER_LOGIN_TOKEN }}
6767
OPEN_SOURCE_BUILDKITEBOT_PUBLIC_REPO_TOKEN: ${{ secrets.OPEN_SOURCE_BUILDKITEBOT_PUBLIC_REPO_TOKEN }}
68+
69+
# Send Slack notification on failure for scheduled or post-merge jobs on master branch
70+
notify_slack_on_failure:
71+
needs:
72+
- precommit
73+
- test
74+
- upload
75+
if: |
76+
failure() &&
77+
github.ref == 'refs/heads/master' &&
78+
(github.event_name == 'schedule' || github.event_name == 'push') &&
79+
!(github.event_name == 'workflow_dispatch' || github.event.schedule == '0 15 * * *')
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Send Slack notification
83+
uses: slackapi/slack-github-action@v2.1.0
84+
with:
85+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
86+
webhook-type: incoming-webhook
87+
payload: |
88+
{
89+
"text": "*Docker cross-version tests and upload workflow failed*",
90+
"blocks": [
91+
{
92+
"type": "section",
93+
"text": {
94+
"type": "mrkdwn",
95+
"text": "*Docker cross-version tests and upload workflow failed*"
96+
}
97+
},
98+
{
99+
"type": "section",
100+
"fields": [
101+
{
102+
"type": "mrkdwn",
103+
"text": "*Workflow:*\n${{ github.workflow }}"
104+
},
105+
{
106+
"type": "mrkdwn",
107+
"text": "*Status:*\nFailed"
108+
},
109+
{
110+
"type": "mrkdwn",
111+
"text": "*Trigger:*\n${{ github.event_name }}"
112+
},
113+
{
114+
"type": "mrkdwn",
115+
"text": "*Branch:*\nmaster"
116+
}
117+
]
118+
},
119+
{
120+
"type": "actions",
121+
"elements": [
122+
{
123+
"type": "button",
124+
"text": {
125+
"type": "plain_text",
126+
"text": "View in GitHub Actions"
127+
},
128+
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
129+
}
130+
]
131+
}
132+
]
133+
}

0 commit comments

Comments
 (0)