mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-02 03:58:36 +01:00
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:
8
.github/workflows/pr-validation.yml
vendored
8
.github/workflows/pr-validation.yml
vendored
@@ -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 {}
|
||||
|
||||
@@ -19,7 +19,13 @@ if (!bodyFile) {
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const body = readFileSync(bodyFile, "utf8").replace(/\r\n/g, "\n");
|
||||
let body;
|
||||
try {
|
||||
body = readFileSync(bodyFile, "utf8").replace(/\r\n/g, "\n");
|
||||
} catch (e) {
|
||||
console.error(`cannot read body file ${bodyFile}: ${e.message}`);
|
||||
process.exit(2);
|
||||
}
|
||||
const association = (process.env.AUTHOR_ASSOCIATION || "").toUpperCase();
|
||||
const isMaintainer = ["OWNER", "MEMBER", "COLLABORATOR"].includes(association);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user