Skip to content
Snippets Groups Projects
Unverified Commit a7b7ba43 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Enhance slack notifier (#30805)

parent e4709df8
Branches
Tags
No related merge requests found
......@@ -28,7 +28,12 @@ jobs:
with:
script: |
const MAX_ATTEMPTS = 2;
const ATTEMPT = ${{ github.event.workflow_run.run_attempt }};
const ATTEMPT = "${{ github.event.workflow_run.run_attempt }}";
const BRANCH = "${{ github.event.workflow_run.head_branch }}";
const FAILED_RUN_URL = "${{ github.event.workflow_run.html_url }}";
const FAILED_RUN_NAME = "${{ github.event.workflow_run.name }}";
const AUTHOR = "${{ github.event.workflow_run.head_commit.author.name }}";
const BREAKING_COMMIT = "${{ github.event.workflow_run.head_sha }}";
if (ATTEMPT <= MAX_ATTEMPTS) {
github.rest.actions.reRunWorkflowFailedJobs({
......@@ -41,10 +46,6 @@ jobs:
const { WebClient } = require('@slack/web-api');
const slack = new WebClient('${{ secrets.SLACK_BOT_TOKEN }}');
const author = `@${context.actor}`;
const breaking_commit = context.sha;
const branch = context.ref;
await slack.chat.postMessage({
channel: 'engineering-ci',
blocks: [
......@@ -52,7 +53,7 @@ jobs:
"type": "header",
"text": {
"type": "plain_text",
"text": `:alert: CI is failing on ${branch} :alert:`,
"text": `:alert: CI is failing on ${BRANCH} :alert:`,
"emoji": true,
}
},
......@@ -64,7 +65,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": `Commit <https://github.com/metabase/metabase/commit/${breaking_commit}|${breaking_commit.slice(0,7)}> by ${author} has failing tests on the \`${branch}\` branch . :sad-panda:\nPlease fix ASAP. Emoji this message when it's fixed.`
"text": `Commit <https://github.com/metabase/metabase/commit/${BREAKING_COMMIT}|${BREAKING_COMMIT.slice(0,7)}> by ${AUTHOR} has failing <${FAILED_RUN_URL}|${FAILED_RUN_NAME}> tests on the \`${BRANCH}\` branch . :sad-panda:\nPlease fix ASAP. \n\nEmoji this message when it's fixed.`
}
},
{
......@@ -77,16 +78,25 @@ jobs:
"text": "Failing Commit",
"emoji": true
},
"url": `https://github.com/metabase/metabase/commit/${breaking_commit}`
"url": `https://github.com/metabase/metabase/commit/${BREAKING_COMMIT}`
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": `Recent commits to ${BRANCH}`,
"emoji": true
},
"url": `https://github.com/metabase/metabase/commits/${BRANCH}`
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Recent commits to master",
"text": "Failed CI Run",
"emoji": true
},
"url": `https://github.com/metabase/metabase/commits/${branch}`
"url": `${FAILED_RUN_URL}`
}
]
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment