From 05f19c25b104135b83eb68ef44bb9fa177af9074 Mon Sep 17 00:00:00 2001 From: JSRCode <139555610+jsrcode@users.noreply.github.com> Date: Mon, 22 Dec 2025 23:05:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=20PR=20Check?= =?UTF-8?q?=20Comment=20workflow=20=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **问题**: - JavaScript 语法错误:SyntaxError: Unexpected identifier 't' - 导致评论 workflow 失败,无法生成评论 **修复**: - 避免使用模板字符串,改用字符串拼接 - 转义特殊字符(单引号) - 简化部分表达式避免潜在的解析问题 **测试**: - 将在下一个 PR 中验证评论功能 --- .github/workflows/pr-check-comment.yml | 85 +++++++++++--------------- 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/.github/workflows/pr-check-comment.yml b/.github/workflows/pr-check-comment.yml index 249e649..d08a1e6 100644 --- a/.github/workflows/pr-check-comment.yml +++ b/.github/workflows/pr-check-comment.yml @@ -2,7 +2,7 @@ name: PR Check Comment on: workflow_run: - workflows: ['PR Check'] + workflows: ["PR Check"] types: - completed @@ -21,21 +21,18 @@ jobs: with: script: | const fs = require('fs'); - const path = require('path'); - // 获取所有 artifacts const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, run_id: context.payload.workflow_run.id, }); - console.log(`Found ${artifacts.data.artifacts.length} artifacts`); + console.log('Found artifacts:', artifacts.data.artifacts.length); - // 下载所有平台的状态文件 for (const artifact of artifacts.data.artifacts) { if (artifact.name.startsWith('pr-check-state-')) { - console.log(`Downloading artifact: ${artifact.name}`); + console.log('Downloading:', artifact.name); const download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, @@ -44,7 +41,7 @@ jobs: archive_format: 'zip', }); - fs.writeFileSync(`${artifact.name}.zip`, Buffer.from(download.data)); + fs.writeFileSync(artifact.name + '.zip', Buffer.from(download.data)); } } @@ -66,49 +63,41 @@ jobs: const path = require('path'); const marker = ''; - const stateMarker = '` + '' ].join('\n'); - // 查找现有评论 const { data: comments } = await github.rest.issues.listComments({ issue_number: prNumber, owner: context.repo.owner, @@ -202,10 +187,10 @@ jobs: per_page: 100 }); - const existing = comments.find((c) => c.body.includes(marker)); + const existing = comments.find(c => c.body.includes(marker)); if (existing) { - console.log(`Updating existing comment #${existing.id}`); + console.log('Updating existing comment', existing.id); await github.rest.issues.updateComment({ comment_id: existing.id, owner: context.repo.owner, From f509a87563a00d38348d34928e8ca83cf876b8f8 Mon Sep 17 00:00:00 2001 From: JSRCode <139555610+jsrcode@users.noreply.github.com> Date: Mon, 22 Dec 2025 23:20:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?style(ci):=20=E6=A0=BC=E5=BC=8F=E5=8C=96=20?= =?UTF-8?q?workflow=20=E6=96=87=E4=BB=B6=E4=BB=A5=E9=80=9A=E8=BF=87=20Pret?= =?UTF-8?q?tier=20=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-check-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-check-comment.yml b/.github/workflows/pr-check-comment.yml index d08a1e6..cba9e12 100644 --- a/.github/workflows/pr-check-comment.yml +++ b/.github/workflows/pr-check-comment.yml @@ -2,7 +2,7 @@ name: PR Check Comment on: workflow_run: - workflows: ["PR Check"] + workflows: ['PR Check'] types: - completed