-
Notifications
You must be signed in to change notification settings - Fork 227
chore: reintroduce slack notif #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: Slack Notifications | ||
|
|
||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| SLACK_BOT_TOKEN: | ||
| required: true | ||
|
Comment on lines
+5
to
+7
|
||
| inputs: | ||
| status: | ||
| description: 'The status of the workflow (success or failure)' | ||
| required: true | ||
| type: string | ||
| actor: | ||
| description: 'The GitHub actor' | ||
| required: true | ||
| type: string | ||
| repository: | ||
| description: 'The GitHub repository' | ||
| required: true | ||
| type: string | ||
| branch: | ||
| description: 'The branch name' | ||
| required: true | ||
| type: string | ||
| run_id: | ||
| description: 'The workflow run ID' | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| notify_slack: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Post to Slack | ||
| run: | | ||
| if [ "${{ inputs.status }}" == "success" ]; then | ||
| payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{ | ||
| "channel": "team-gnark-build", | ||
| "text": "GitHub Action build result: success", | ||
| "blocks": [ | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": ":large_green_circle: *All checks have passed:* *\($branch)* :white_check_mark:" | ||
| }, | ||
| }, | ||
|
Comment on lines
+41
to
+47
|
||
| { | ||
| "type": "context", | ||
| "elements": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "\($repository) -- \($actor) -- <https://github.com/\($repository)/actions/runs/\($run_id)|View details>" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }') | ||
| else | ||
| payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{ | ||
| "channel": "team-gnark-build", | ||
| "text": "GitHub Action build result: failure", | ||
| "blocks": [ | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": ":red_circle: *Failed run:* *\($branch)*" | ||
| }, | ||
| }, | ||
|
Comment on lines
+64
to
+70
|
||
| { | ||
| "type": "context", | ||
| "elements": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "\($repository) -- \($actor) -- <https://github.com/\($repository)/actions/runs/\($run_id)|View details>" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }') | ||
| fi | ||
| response=$(curl -s -X POST -H 'Content-type: application/json; charset=utf-8' --data "$payload" https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" ) | ||
| shell: bash | ||
|
Comment on lines
+35
to
+84
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This job always runs on
pull_request, butSLACK_BOT_TOKENwon't be available for PRs from forks, and the reusable workflow currently requires it. That will make forked PR checks fail. Add anif:guard to skip on forked PRs (e.g., whengithub.event.pull_request.head.repo.full_name != github.repository) and/or adjust the reusable workflow secret requirement to be optional with a graceful no-op.