From 4fe42094365a213dda59e74423ba974c777a8e55 Mon Sep 17 00:00:00 2001 From: Okan Sahin Date: Tue, 7 May 2024 16:08:11 +0200 Subject: [PATCH] Add a high impact slack webhook --- .github/workflows/helpers.js | 4 ++-- .github/workflows/merge-to-stage.js | 10 ++++++++-- .github/workflows/merge-to-stage.yaml | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/helpers.js b/.github/workflows/helpers.js index 8cfb11fd14..da3565c095 100644 --- a/.github/workflows/helpers.js +++ b/.github/workflows/helpers.js @@ -22,9 +22,9 @@ Then run: node --env-file=.env .github/workflows/update-ims.js`); }; }; -const slackNotification = (text) => { +const slackNotification = (text, webhook) => { console.log(text); - return fetch(process.env.MILO_RELEASE_SLACK_WH, { + return fetch(webhook || process.env.MILO_RELEASE_SLACK_WH, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/.github/workflows/merge-to-stage.js b/.github/workflows/merge-to-stage.js index efbc6ce1d4..759a02cae3 100644 --- a/.github/workflows/merge-to-stage.js +++ b/.github/workflows/merge-to-stage.js @@ -85,7 +85,6 @@ const RCPDates = [ ]; const isHighPrio = (labels) => labels.includes(LABELS.highPriority); -const isHighImpact = (labels) => labels.includes(LABELS.highImpact); const hasFailingChecks = (checks) => checks.some( @@ -138,12 +137,19 @@ const merge = async ({ prs }) => { if (!process.env.LOCAL_RUN) await github.rest.pulls.merge({ owner, repo, pull_number: number }); body = `- [${title}](${html_url})\n${body}`; + const isHighImpact = labels.includes(LABELS.highImpact); + if (isHighImpact && process.env.SLACK_HIGH_IMPACT_PR_WEBHOOK) { + await slackNotification( + SLACK.merge({ html_url, number, title, highImpact: ' :alert:' }), + process.env.SLACK_HIGH_IMPACT_PR_WEBHOOK + ); + } await slackNotification( SLACK.merge({ html_url, number, title, - highImpact: isHighImpact(labels) ? ' :alert:' : '', + highImpact: isHighImpact ? ' :alert:' : '', }) ); } diff --git a/.github/workflows/merge-to-stage.yaml b/.github/workflows/merge-to-stage.yaml index 3310906661..4187295192 100644 --- a/.github/workflows/merge-to-stage.yaml +++ b/.github/workflows/merge-to-stage.yaml @@ -10,6 +10,7 @@ on: env: MILO_RELEASE_SLACK_WH: ${{ secrets.MILO_RELEASE_SLACK_WH }} REQUIRED_APPROVALS: ${{ secrets.REQUIRED_APPROVALS }} + SLACK_HIGH_IMPACT_PR_WEBHOOK: ${{ secrets.SLACK_HIGH_IMPACT_PR_WEBHOOK }} jobs: merge-to-stage: