File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 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
1414permissions :
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
You can’t perform that action at this time.
0 commit comments