Skip to content

Commit

Permalink
Stage automation, update the body after merging another PR in (#2289)
Browse files Browse the repository at this point in the history
* Stage process improvements

* Remove team reviewers

* Formatting

* Simplify PR bodies

---------

Co-authored-by: Robert Bogos <146744221+robert-bogos@users.noreply.github.com>
  • Loading branch information
mokimo and robert-bogos authored May 14, 2024
1 parent b617478 commit 3b3fd6f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const merge = async ({ prs }) => {
merge_method: 'squash',
});
}
body = `- [${title}](${html_url})\n${body}`;
body = `- ${html_url}\n${body}`;
const isHighImpact = labels.includes(LABELS.highImpact);
if (isHighImpact && process.env.SLACK_HIGH_IMPACT_PR_WEBHOOK) {
await slackNotification(
Expand Down Expand Up @@ -184,8 +184,7 @@ const openStageToMainPR = async () => {
});

for (const pr of pullRequestData) {
if (!body.includes(pr.html_url))
body = `- [${pr.title}](${pr.html_url})\n${body}`;
if (!body.includes(pr.html_url)) body = `- ${pr.html_url}\n${body}`;
}
}

Expand Down Expand Up @@ -227,12 +226,22 @@ const main = async (params) => {
try {
const stageToMainPR = await getStageToMainPR();
console.log('has Stage to Main PR:', !!stageToMainPR);
if (stageToMainPR) body = stageToMainPR.body;
if (stageToMainPR?.labels.some((label) => label.includes(LABELS.SOTPrefix)))
return console.log('PR exists & testing started. Stopping execution.');
const prs = await getPRs();
await merge({ prs: prs.filter(({ labels }) => isHighPrio(labels)) });
await merge({ prs: prs.filter(({ labels }) => !isHighPrio(labels)) });
if (!stageToMainPR) await openStageToMainPR();
if (body !== stageToMainPR?.body) {
console.log("Updating PR's body...");
await github.rest.pulls.update({
owner,
repo,
pull_number: stageToMainPR.number,
body: body,
});
}
console.log('Process successfully executed.');
} catch (error) {
console.error(error);
Expand Down

0 comments on commit 3b3fd6f

Please sign in to comment.