Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a high impact slack webhook #60

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Those env variables are set by an github action automatically

Check warning on line 1 in .github/workflows/helpers.js

View workflow job for this annotation

GitHub Actions / Running eslint

[eslint] reported by reviewdog 🐶 File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'") to override. Raw Output: {"fatal":false,"severity":1,"message":"File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override."}
// For local testing, you should test on your fork.
const owner = process.env.REPO_OWNER || ''; // example owner: adobecom
const repo = process.env.REPO_NAME || ''; // example repo name: milo
Expand All @@ -22,9 +22,9 @@
};
};

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',
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {

Check warning on line 1 in .github/workflows/merge-to-stage.js

View workflow job for this annotation

GitHub Actions / Running eslint

[eslint] reported by reviewdog 🐶 File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'") to override. Raw Output: {"fatal":false,"severity":1,"message":"File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override."}
slackNotification,
getLocalConfigs,
pulls: { addLabels, addFiles, getChecks, getReviews },
Expand Down Expand Up @@ -85,7 +85,6 @@
];

const isHighPrio = (labels) => labels.includes(LABELS.highPriority);
const isHighImpact = (labels) => labels.includes(LABELS.highImpact);

const hasFailingChecks = (checks) =>
checks.some(
Expand Down Expand Up @@ -138,12 +137,19 @@
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:' : '',
})
);
}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/merge-to-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading