Skip to content

Commit 9a228f1

Browse files
committed
Add slack notification on build failure
commit-id:960efd4f
1 parent 17fe63f commit 9a228f1

1 file changed

Lines changed: 68 additions & 1 deletion

File tree

.github/workflows/cross_version_test.yml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
with:
5555
bf_version: ${{ needs.precommit.outputs.bf_version }}
5656
# Consider manual builds or 8AM Pacific scheduled builds as a release candidate
57-
queue_prod_release: ${{ github.event_name == 'workflow_dispatch' || github.event.schedule == '0 15 * * *' }}
57+
queue_prod_release: false
5858
test_tag: "test-${{ needs.precommit.outputs.bf_version }}"
5959
release_tag: "${{ needs.precommit.outputs.bf_version }}"
6060
BATFISH_GITHUB_BATFISH_REPO: "${{ needs.precommit.outputs.batfish_repo }}"
@@ -64,3 +64,70 @@ jobs:
6464
PYBATFISH_PYPI_TOKEN: ${{ secrets.PYBATFISH_PYPI_TOKEN }}
6565
BATFISH_DOCKER_LOGIN_TOKEN: ${{ secrets.BATFISH_DOCKER_LOGIN_TOKEN }}
6666
OPEN_SOURCE_BUILDKITEBOT_PUBLIC_REPO_TOKEN: ${{ secrets.OPEN_SOURCE_BUILDKITEBOT_PUBLIC_REPO_TOKEN }}
67+
68+
# Send Slack notification on failure for scheduled or post-merge jobs on master branch
69+
notify_slack_on_failure:
70+
needs:
71+
- precommit
72+
- test
73+
- upload
74+
if: |
75+
always()
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:*\nDocker cross-version tests and upload"
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 Workflow Run 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)