Skip to content

Commit

Permalink
Feat(MWPW-154091):Prs must contain verified label. (#370)
Browse files Browse the repository at this point in the history
* prs must contain verified label
* month and date added to the title of stage to main PR
  • Loading branch information
sharath-kannan authored Jul 29, 2024
1 parent 7b0fe78 commit 9310cff
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const STAGE = 'stage';

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."}
const PROD = 'main';
const PR_TITLE = '[Release] Stage to Main';
const PR_TITLE = `[Release] Stage to Main ${new Date().toLocaleDateString("en-US", { month: "2-digit", day: "2-digit" })}`;
const SEEN = {};
let github, owner, repo;
let body = `
Expand All @@ -14,6 +14,7 @@ const LABELS = {
readyForStage: 'Ready for Stage',
SOTPrefix: 'SOT',
zeroImpact: 'zero-impact',
verified: 'verified',
};
const TEAM_MENTIONS = [
'@adobecom/creative-cloud-sot',
Expand Down Expand Up @@ -181,14 +182,21 @@ const getPRs = async () => {
...prs.map((pr) => getChecks({ pr, github, owner, repo })),
...prs.map((pr) => getReviews({ pr, github, owner, repo })),
]);
prs = prs.filter(({ checks, reviews, number, title }) => {
prs = prs.filter(({ checks, reviews, number, title, labels }) => {
if (hasFailingChecks(checks)) {
commentOnPR(
`Skipped merging ${number}: ${title} due to failing checks`,
number
);
return false;
}
if (!labels.includes(LABELS.verified)) {
commentOnPR(
`Skipped merging ${number}: ${title} due to missing verified label. kindly make sure that the PR has been verified`,
number
);
return false;
}

const approvals = reviews.filter(({ state }) => state === 'APPROVED');
if (approvals.length < REQUIRED_APPROVALS) {
Expand Down Expand Up @@ -219,7 +227,7 @@ const getPRs = async () => {
const getStageToMainPR = () =>
github.rest.pulls
.list({ owner, repo, state: 'open', base: PROD })
.then(({ data } = {}) => data.find(({ title } = {}) => title === PR_TITLE))
.then(({ data } = {}) => data.find(({ title } = {}) => title.includes('[Release] Stage to Main')))
.then((pr) => pr && addLabels({ pr, github, owner, repo }))
.then((pr) => pr && addFiles({ pr, github, owner, repo }))
.then((pr) => {
Expand Down

0 comments on commit 9310cff

Please sign in to comment.