Skip to content

Conversation

@jsrcode
Copy link
Collaborator

@jsrcode jsrcode commented Dec 22, 2025

问题描述

PR #66 测试时发现 PR Check Comment workflow 执行失败,错误信息:

SyntaxError: Unexpected identifier 't'

根本原因:GitHub Actions 的 actions/github-script@v7 在解析包含模板字符串的脚本时存在语法解析问题。

解决方案

将所有 JavaScript 模板字符串(`...${var}...`)改写为字符串拼接('...' + var + '...'):

修改前

const detail = (entry) => `check=${entry.check} / fix=${entry.fix} / recheck=${entry.recheck}`;
const linkOrDash = (entry) => entry.run_url ? `[日志](${entry.run_url})` : '-';

修改后

const detail = (entry) => 'check=' + entry.check + ' / fix=' + entry.fix + ' / recheck=' + entry.recheck;
const linkOrDash = (entry) => entry.run_url ? '[日志](' + entry.run_url + ')' : '-';

主要改动

  1. 所有模板字符串替换为 + 拼接
  2. 转义单引号:can'tcan\'t
  3. 简化表达式,避免嵌套模板字符串

测试计划

  • 合并后在新 PR 上验证 workflow 执行成功
  • 确认评论内容格式正确(双语表格 + 状态更新)
  • 测试 fork PR 场景(跨仓库评论权限)

相关 PR

**问题**:
- JavaScript 语法错误:SyntaxError: Unexpected identifier 't'
- 导致评论 workflow 失败,无法生成评论

**修复**:
- 避免使用模板字符串,改用字符串拼接
- 转义特殊字符(单引号)
- 简化部分表达式避免潜在的解析问题

**测试**:
- 将在下一个 PR 中验证评论功能
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant