fix(pr-validation): paginate issue comments + guard unreadable body file

Addresses review: github.rest.issues.listComments only returns the first page,
so the sticky-comment marker could be missed on busy PRs — use github.paginate.
And guard readFileSync so a missing/unreadable body file exits 2 (per the doc)
instead of crashing without JSON.
This commit is contained in:
Gauvino
2026-06-01 20:22:28 +02:00
parent 5f59dce0c7
commit 935cacff81
2 changed files with 11 additions and 5 deletions

View File

@@ -111,8 +111,8 @@ jobs:
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
const marker = "<!-- pr-template-check -->";
const comments = await github.rest.issues.listComments({ owner, repo, issue_number });
const existing = comments.data.find((c) => c.body?.includes(marker));
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number });
const existing = comments.find((c) => c.body?.includes(marker));
const payload = `${marker}\n${body}`;
if (existing) await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body: payload });
else await github.rest.issues.createComment({ owner, repo, issue_number, body: payload });
@@ -130,7 +130,7 @@ jobs:
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
const marker = "<!-- pr-template-check -->";
const comments = await github.rest.issues.listComments({ owner, repo, issue_number });
const existing = comments.data.find((c) => c.body?.includes(marker));
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number });
const existing = comments.find((c) => c.body?.includes(marker));
if (existing) await github.rest.issues.deleteComment({ owner, repo, comment_id: existing.id });
try { await github.rest.issues.removeLabel({ owner, repo, issue_number, name: "blocked: template" }); } catch {}