Skip to content

Commit f18d1b5

Browse files
committed
Add slack notification on build failure
commit-id:84f04bab
1 parent 8b0ac40 commit f18d1b5

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

.github/workflows/cross_version_test.yml

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

0 commit comments

Comments
 (0)