Skip to content

Commit dc24972

Browse files
rscohn2normallytangent
authored andcommitted
[CI]: support pagination when fetching the files changed in the PR (#540)
1 parent 5322614 commit dc24972

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

.github/scripts/domain-check.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,32 @@ function matchesPattern(domain, filePaths) {
2424

2525
// Return the list of files modified in the pull request
2626
async function prFiles(github, context) {
27-
const response = await github.rest.pulls.listFiles({
28-
owner: context.repo.owner,
29-
repo: context.repo.repo,
30-
pull_number: context.payload.pull_request.number,
31-
});
32-
const prFiles = response.data.map((file) => file.filename);
33-
return prFiles;
27+
let allFiles = [];
28+
let page = 0;
29+
let filesPerPage = 100; // GitHub's maximum per page
30+
31+
while (true) {
32+
page++;
33+
const response = await github.rest.pulls.listFiles({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
pull_number: context.payload.pull_request.number,
37+
per_page: filesPerPage,
38+
page: page,
39+
});
40+
41+
if (response.data.length === 0) {
42+
break; // Exit the loop if no more files are returned
43+
}
44+
45+
allFiles = allFiles.concat(response.data.map((file) => file.filename));
46+
47+
if (response.data.length < filesPerPage) {
48+
break; // Exit the loop if last page
49+
}
50+
}
51+
52+
return allFiles;
3453
}
3554

3655
// Called by pr.yml. See:

0 commit comments

Comments
 (0)