Skip to content

Commit 20742ca

Browse files
committed
fix: optimize pagination for PR comments retrieval in lint workflow
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent f76de00 commit 20742ca

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

.github/workflows/pr-title-jira-key-lint.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,22 @@ jobs:
2727
console.log(`PR Title: ${prTitle}`);
2828
2929
const existingComment = await (async () => {
30-
const iterator = github.paginate.iterator(github.rest.issues.listComments, {
31-
owner,
32-
repo,
33-
issue_number: prNumber,
34-
per_page: 100,
35-
});
36-
for await (const { data: comments } of iterator) {
30+
const perPage = 100;
31+
for (let page = 1; ; page += 1) {
32+
const { data: comments } = await github.rest.issues.listComments({
33+
owner,
34+
repo,
35+
issue_number: prNumber,
36+
per_page: perPage,
37+
page,
38+
});
39+
3740
const found = comments.find(
3841
(c) => c.user?.type === 'Bot' && c.body?.includes(COMMENT_MARKER),
3942
);
4043
if (found) return found;
44+
if (comments.length < perPage) return null;
4145
}
42-
return null;
4346
})();
4447
4548
if (!jiraKeyRegex.test(prTitle)) {

0 commit comments

Comments
 (0)