Skip to content

Commit e8ed81e

Browse files
committed
fix(github-actions): branch manager incorrectly syncs all PRs
The branch manager logic for syncing merge ready PRs is flawed and currently always causes all PRs to be synced. This can be quite a lot, especially in repos like FW. This caused queueing of GitHub actions in the dev-infra repo and slowed down updates of the mergeability status. Related to: #998
1 parent fa428ee commit e8ed81e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

github-actions/branch-manager/lib/main.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ async function run() {
2727
}
2828

2929
core.info(`Evaluating pull requests as a result of a push to '${ref}'`);
30+
31+
const mergeReadyPrQuery =
32+
`repo:${context.repo.owner}/${context.repo.repo} ` +
33+
`is:pr ` +
34+
`is:open ` +
35+
`label:"${actionLabels.ACTION_MERGE.name}"`;
36+
3037
const prs = await github().then((api) =>
3138
api.paginate(
32-
api.pulls.list,
33-
{...context.repo, state: 'open', labels: actionLabels.ACTION_MERGE.name},
34-
(pulls) => pulls.data.map((pull) => `${pull.number}`),
39+
api.search.issuesAndPullRequests,
40+
{
41+
q: mergeReadyPrQuery,
42+
},
43+
(issues) => issues.data.map((i) => `${i.number}`),
3544
),
3645
);
3746
core.info(`Triggering ${prs.length} prs to be evaluated`);

github-actions/branch-manager/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23535,7 +23535,10 @@ async function run() {
2353523535
return;
2353623536
}
2353723537
core.info(`Evaluating pull requests as a result of a push to '${ref}'`);
23538-
const prs = await github().then((api) => api.paginate(api.pulls.list, { ...import_github2.context.repo, state: "open", labels: actionLabels.ACTION_MERGE.name }, (pulls) => pulls.data.map((pull) => `${pull.number}`)));
23538+
const mergeReadyPrQuery = `repo:${import_github2.context.repo.owner}/${import_github2.context.repo.repo} is:pr is:open label:"${actionLabels.ACTION_MERGE.name}"`;
23539+
const prs = await github().then((api) => api.paginate(api.search.issuesAndPullRequests, {
23540+
q: mergeReadyPrQuery
23541+
}, (issues) => issues.data.map((i) => `${i.number}`)));
2353923542
core.info(`Triggering ${prs.length} prs to be evaluated`);
2354023543
for (const pr of prs) {
2354123544
await createWorkflowForPullRequest({ pr });

0 commit comments

Comments
 (0)