From 1c29f986c38b620dc4c651029f005753ee6af595 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 18 Jun 2026 05:24:17 +0800 Subject: [PATCH] chore: reuse comments --- .../workflow/test-issue/call-maintainer.mjs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/workflow/test-issue/call-maintainer.mjs b/scripts/workflow/test-issue/call-maintainer.mjs index 936021f3b..1e35f3b1d 100644 --- a/scripts/workflow/test-issue/call-maintainer.mjs +++ b/scripts/workflow/test-issue/call-maintainer.mjs @@ -176,19 +176,24 @@ export default async function callMaintainer({ github, context, core }) { // Write labels (status, affected route count) await addLabels(labels); - // Reply to the issue and notify the maintainers (if any) - try { - await github.rest.issues.createComment({ - ...issueFacts, - body: `${comments} - - + const commentBody = `${comments} > To maintainers: if you are not willing to be disturbed, list your username in \`scripts/workflow/test-issue/call-maintainer.js\`. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified. If all routes can not be found, the issue will be closed automatically. Please use \`NOROUTE\` for a route-irrelevant issue or leave a comment if it is a mistake. 如果所有路由都无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 \`NOROUTE\` 关键词,或者留下评论。我们会重新审核。 -`, - }); +`; + + // Reply to the issue and notify the maintainers (if any), reusing the existing comment if the issue was edited + try { + const existing = await github.paginate(github.rest.issues.listComments, issueFacts); + const comment = existing.find((c) => c.user.type === 'Bot' && c.body.startsWith('##### Searching for maintainers:')); + if (comment) { + if (comment.body !== commentBody) { + await github.rest.issues.updateComment({ ...issueFacts, comment_id: comment.id, body: commentBody }); + } + } else { + await github.rest.issues.createComment({ ...issueFacts, body: commentBody }); + } } catch (error) { core.warning(error); }