Skip to content

๐Ÿ“ฎ Slack Message Broker #9841

๐Ÿ“ฎ Slack Message Broker

๐Ÿ“ฎ Slack Message Broker #9841

# 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 specified Slack channel ids.
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
payload: |
{
"text": "${{ steps.prepare-slack-message.outputs.message }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ steps.prepare-slack-message.outputs.message }}"
}
}
]
}