From 2789b3701d509f5d381d432d3123882d3721528d Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 29 Mar 2022 16:23:06 +0200 Subject: [PATCH] ci: skip ci failure slack notifications for renovate branches (#24692) We want to skip CI failure Slack notifications for upstream branches which are not actual publish branches. Please enter the commit message for your changes. Lines starting (cherry picked from commit 9cb96aae01a2bbbc561ab2791ab7c3f044d2bb18) --- scripts/circleci/notify-slack-job-failure.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/circleci/notify-slack-job-failure.js b/scripts/circleci/notify-slack-job-failure.js index 81620cc39a8c..3b4ef45cd29c 100644 --- a/scripts/circleci/notify-slack-job-failure.js +++ b/scripts/circleci/notify-slack-job-failure.js @@ -5,12 +5,17 @@ * will be a noop when running for forked builds (i.e. PRs). */ +const { + isVersionBranch, + getConfig, + assertValidGithubConfig, +} = require('@angular/dev-infra-private/ng-dev'); + if (process.env.CIRCLE_PR_NUMBER) { console.info('Skipping notifications for pull requests.'); process.exit(0); } -const {echo, set} = require('shelljs'); const { CIRCLE_JOB: jobName, CIRCLE_BRANCH: branchName, @@ -18,6 +23,17 @@ const { SLACK_COMPONENTS_CI_FAILURES_WEBHOOK_URL: webhookUrl, } = process.env; +const {github} = getConfig([assertValidGithubConfig]); +const isPublishBranch = isVersionBranch(branchName) || branchName === github.mainBranchName; + +// We don't want to spam the CI failures channel with e.g. Renovate branch failures. +if (isPublishBranch === false) { + console.info('Skipping notifications for non-publish branches.'); + process.exit(0); +} + +const {echo, set} = require('shelljs'); + const text = `\`${jobName}\` failed in branch: ${branchName}: ${jobUrl}`; const payload = {text}; const [channelName] = process.argv.slice(2);