Skip to content

Commit

Permalink
[merge to stage automation] Remove superfluent slacks to the changelog (
Browse files Browse the repository at this point in the history
#2278)

* Remove superfluent slacks

* Remove unused messages
  • Loading branch information
mokimo authored May 8, 2024
1 parent dc6693f commit 73af8b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
23 changes: 5 additions & 18 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ const LABELS = {
};

const SLACK = {
fileOverlap: ({ html_url, number, title }) =>
`:fast_forward: Skipping <${html_url}|${number}: ${title}> due to overlap in files.`,
merge: ({ html_url, number, title, highImpact }) =>
`:merged:${highImpact} PR merged to stage: <${html_url}|${number}: ${title}>.`,
failingChecks: ({ html_url, number, title }) =>
`:x: Skipping <${html_url}|${number}: ${title}> due to failing checks`,
requireApprovals: ({ html_url, number, title }) =>
`:x: Skipping <${html_url}|${number}: ${title}> due to insufficient approvals`,
openedSyncPr: ({ html_url, number }) =>
`:fast_forward: Created <${html_url}|Stage to Main PR ${number}>`,
};

let github, owner, repo, currPrNumber, core;
let github, owner, repo;

let body = `
## common base root URLs
Expand Down Expand Up @@ -104,19 +98,15 @@ const getPRs = async () => {
...prs.map((pr) => getReviews({ pr, github, owner, repo })),
]);

prs = prs.filter(({ checks, reviews, html_url, number, title }) => {
prs = prs.filter(({ checks, reviews, number, title }) => {
if (hasFailingChecks(checks)) {
slackNotification(SLACK.failingChecks({ html_url, number, title }));
if (number === currPrNumber)
core.setFailed(`Failing checks on the current PR ${number}`);
console.log(`Skipping ${number}: ${title} due to failing checks`);
return false;
}

const approvals = reviews.filter(({ state }) => state === 'APPROVED');
if (approvals.length < REQUIRED_APPROVALS) {
slackNotification(SLACK.requireApprovals({ html_url, number, title }));
if (number === currPrNumber)
core.setFailed(`Insufficient approvals on the current PR ${number}`);
console.log(`Skipping ${number}: ${title} due to insufficient approvals`);
return false;
}

Expand All @@ -130,7 +120,7 @@ const merge = async ({ prs }) => {
console.log(`Merging ${prs.length || 0} PRs that are ready... `);
for await (const { number, files, html_url, title, labels } of prs) {
if (files.some((file) => SEEN[file])) {
await slackNotification(SLACK.fileOverlap({ html_url, number, title }));
console.log(`Skipping ${number}: ${title} due to overlap in files.`);
continue;
}
files.forEach((file) => (SEEN[file] = true));
Expand Down Expand Up @@ -222,8 +212,6 @@ const main = async (params) => {
github = params.github;
owner = params.context.repo.owner;
repo = params.context.repo.repo;
currPrNumber = params.context.issue?.number;
core = params.core;

const now = new Date();
// We need to revisit this every year
Expand Down Expand Up @@ -256,7 +244,6 @@ if (process.env.LOCAL_RUN) {
main({
github,
context,
core: { setFailed: console.error },
});
}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge-to-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
github-token: ${{ steps.milo-pr-merge-token.outputs.token }}
script: |
const main = require('./.github/workflows/merge-to-stage.js')
main({ github, context, core })
main({ github, context })

0 comments on commit 73af8b8

Please sign in to comment.