Skip to content

๐Ÿ“ฎ Slack Message Broker #43

๐Ÿ“ฎ Slack Message Broker

๐Ÿ“ฎ Slack Message Broker #43

# 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 }}"
}
}
]
}