Skip to content

Commit c117d2d

Browse files
committed
Build/Test Tools: Switch to the GraphQL API for searching pull requests.
The GraphQL API is more flexible and efficient than the REST API. This switches the pull request search code to use the former. Fixes #63278. git-svn-id: https://develop.svn.wordpress.org/trunk@60315 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6493acc commit c117d2d

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

.github/workflows/reusable-cleanup-pull-requests.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,32 @@ jobs:
5050
with:
5151
script: |
5252
const fixedList = "${{ steps.trac-tickets.outputs.fixed_list }}".split(' ').filter(Boolean);
53-
5453
let prNumbers = [];
5554
5655
for (const ticket of fixedList) {
57-
const tracTicketUrl = `https://core.trac.wordpress.org/ticket/${ ticket }`;
58-
const corePrefix = `Core-${ ticket }`;
59-
const query = `is:pr is:open repo:${ context.repo.owner }/${ context.repo.repo } in:body ${ tracTicketUrl } OR ${ corePrefix }`;
60-
const result = await github.rest.search.issues({ q: query });
56+
const tracTicketUrl = `https://core.trac.wordpress.org/ticket/${ticket}`;
57+
const corePrefix = `Core-${ticket}`;
58+
59+
const query = `
60+
query($searchQuery: String!) {
61+
search(query: $searchQuery, type: ISSUE_ADVANCED, first: 20) {
62+
nodes {
63+
... on PullRequest {
64+
number
65+
state
66+
}
67+
}
68+
}
69+
}
70+
`;
71+
72+
const searchQuery = `repo:${context.repo.owner}/${context.repo.repo} is:pr is:open in:body ( "${tracTicketUrl}" OR "${corePrefix}" )`;
73+
74+
const result = await github.graphql(query, {
75+
searchQuery,
76+
});
6177
62-
prNumbers = prNumbers.concat(result.data.items.map(pr => pr.number));
78+
prNumbers.push(...result.search.nodes.map(pr => pr.number));
6379
}
6480
6581
return prNumbers;

0 commit comments

Comments
 (0)