Skip to content

Commit a021355

Browse files
authored
gha: Fix over-eager info-needed closer (#2233)
1 parent fac4943 commit a021355

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

.github/workflows/info-needed-closer.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ on:
66
workflow_call:
77
inputs:
88
days:
9-
description: 'Number of days without activity before closing (default: 14)'
9+
description: "Number of days without activity before closing (default: 14)"
1010
required: false
1111
type: string
12-
default: '14'
12+
default: "14"
1313

1414
permissions:
1515
issues: write
@@ -78,18 +78,24 @@ jobs:
7878
continue;
7979
}
8080
81-
// Fetch only the most recent comment for the issue
81+
// The listComments endpoint returns comments in ascending chronological
82+
// order and does not support sort/direction params. Use the issue's
83+
// comment count to jump directly to the last page.
84+
if (issue.comments === 0) {
85+
core.info(`Issue #${issue.number}: no comments, skipping`);
86+
continue;
87+
}
88+
8289
const { data: comments } = await github.rest.issues.listComments({
8390
owner: context.repo.owner,
8491
repo: context.repo.repo,
8592
issue_number: issue.number,
8693
per_page: 1,
87-
sort: 'created',
88-
direction: 'desc',
94+
page: issue.comments, // Jump to the last page (with per_page=1), to get the last comment directly
8995
});
9096
9197
if (comments.length === 0) {
92-
core.info(`Issue #${issue.number}: no comments, skipping`);
98+
core.info(`Issue #${issue.number}: could not fetch last comment, skipping`);
9399
continue;
94100
}
95101

0 commit comments

Comments
 (0)