Skip to content

Commit 9b5fcc5

Browse files
ci: send slack message when ci fails on main (#60)
<!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/starkware-libs/starknet-staking/60) <!-- Reviewable:end --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds a reusable Slack notification workflow and hooks it into the main branch pipeline to alert when the test job fails. > > - **CI/CD**: > - **New reusable workflow** `./.github/workflows/notify-slack.yaml` to send Slack alerts via incoming webhook on CI failure, parameterized by `context_title` and `failed_job_name`. > - **Main pipeline update** in `./.github/workflows/on-merge.yaml`: > - Adds `notify-slack` job that runs after `test` and triggers only on failure, passing context for "main branch" and the failed job name. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 193fe34. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 407cf62 commit 9b5fcc5

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Notify Slack on Failure
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
context_title:
7+
required: true
8+
type: string
9+
description: The context title (e.g., "PR #123: Title" or "main branch")
10+
failed_job_name:
11+
required: true
12+
type: string
13+
description: The name of the failed job
14+
secrets:
15+
SLACK_WEBHOOK_URL:
16+
required: true
17+
18+
jobs:
19+
notify-slack:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Send Slack Notification
23+
uses: slackapi/slack-github-action@v2.1.1
24+
with:
25+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
26+
webhook-type: incoming-webhook
27+
28+
payload: |
29+
text: "@channel CI failed on ${{ inputs.context_title }}"
30+
blocks:
31+
- type: "section"
32+
text:
33+
type: "mrkdwn"
34+
text: "<!channel> :rotating_light: *CI FAILED on ${{ inputs.context_title }}*"
35+
36+
- type: "section"
37+
fields:
38+
- type: "mrkdwn"
39+
text: "*Workflow:*\n`${{ github.workflow }}`"
40+
- type: "mrkdwn"
41+
text: "*Failed Job:*\n`${{ inputs.failed_job_name }}`"
42+
- type: "mrkdwn"
43+
text: "*Commit:*\n`${{ github.sha }}`"
44+
- type: "mrkdwn"
45+
text: "*Author:*\n`${{ github.actor }}`"
46+
47+
- type: "section"
48+
text:
49+
type: "mrkdwn"
50+
text: "<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View failed job run>"
51+

.github/workflows/on-merge.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,12 @@ jobs:
99
test:
1010
uses: ./.github/workflows/test.yaml
1111
secrets: inherit
12+
13+
notify-slack:
14+
needs: test
15+
if: failure()
16+
uses: ./.github/workflows/notify-slack.yaml
17+
with:
18+
context_title: "main branch"
19+
failed_job_name: "test"
20+
secrets: inherit

0 commit comments

Comments
 (0)