Skip to content

Commit

Permalink
ci: skip ci failure slack notifications for renovate branches (angula…
Browse files Browse the repository at this point in the history
…r#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
  • Loading branch information
devversion authored and forsti0506 committed Apr 3, 2022
1 parent 457dd61 commit df91a95
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion scripts/circleci/notify-slack-job-failure.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,35 @@
* 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,
CIRCLE_BUILD_URL: jobUrl,
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);
Expand Down

0 comments on commit df91a95

Please sign in to comment.