๐ฎ Slack Message Broker #37
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 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] | |
# if: contains(fromJson('["success", "failure", "null", "skipped", "cancelled", "action_required", "neutral", "timed_out"]'), github.event.workflow_run.conclusion) | |
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 action = "${{ github.event.action }}"; | |
const conclusion = "${{ github.event.workflow_run.conclusion }}"; | |
const message = `Workflow '${name}' \`${action}\`: \`${status}\`, \`${conclusion}\`, <${url}|View Logs>`; | |
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 }}" | |
} | |
} | |
] | |
} | |