๐ฎ Slack Message Broker #12880
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow is triggered whenever any of the workflows listed in on.workflow_run.workflows | |
# has been cancelled or has failed, and will send a message to the plutus-ci channel. | |
name: "๐ฎ Slack Message Broker" | |
on: | |
workflow_run: | |
types: [completed, requested, in_progress] | |
workflows: | |
- "๐ฝ Cardano Constitution Tests" | |
- "๐ฐ Cost Model Benchmark" | |
- "๐ฆ Docusaurus Site" | |
- "๐ Haddock Site" | |
- "๐ฉบ Longitudinal Benchmark" | |
- "๐ฎ Metatheory Site" | |
- "๐ Nightly Testsuite" | |
- "๐ Papers & Specs" | |
jobs: | |
Send: | |
runs-on: [ubuntu-latest] | |
steps: | |
- name: Prepare Slack Message | |
uses: actions/github-script@main | |
id: prepare-slack-message | |
with: | |
script: | | |
const name = "${{ github.event.workflow_run.name }}"; | |
const url = "${{ github.event.workflow_run.html_url }}"; | |
const status = "${{ github.event.workflow_run.status }}"; | |
const conclusion = "${{ github.event.workflow_run.conclusion }}"; | |
const failure_conclusions = [ "failure", "null", "cancelled", "action_required", "neutral", "timed_out" ]; | |
let message = ""; | |
if (conclusion == "") { | |
message = `${name} \`${status}\` โณ <${url}|View Logs>`; | |
} | |
else if (conclusion == "success") { | |
message = `${name} \`${conclusion}\` โ <${url}|View Logs>`; | |
} | |
else if (conclusion == "skipped") { | |
message = `${name} \`${conclusion}\` โฉ <${url}|View Logs>`; | |
} | |
else if (failure_conclusions.includes(conclusion)) { | |
message = `${name} \`${conclusion}\` โ <${url}|View Logs> @channel`; | |
} | |
else { | |
message = `${name} \`${conclusion}\` โ๏ธ <${url}|View Logs> Unknown Conclusion @channel`; | |
} | |
console.log(message); | |
core.setOutput("message", message); | |
- name: Notify Slack | |
uses: slackapi/[email protected] | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
with: | |
channel-id: C07A1GSNZEE # plutus-ci | |
payload: | | |
{ | |
"text": "${{ steps.prepare-slack-message.outputs.message }}", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "${{ steps.prepare-slack-message.outputs.message }}" | |
} | |
} | |
] | |
} | |