From 1640ba2e9e8c0449e4e3ed0b7d2997bfbb977fe6 Mon Sep 17 00:00:00 2001 From: Phantom <59059173+EurFelux@users.noreply.github.com> Date: Sat, 6 Sep 2025 16:22:46 +0800 Subject: [PATCH] CI: update translator workflow (#9972) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create translator.yml * update * try with cc * ci: 修改文件名translator为claude-translator * ci(workflow): 更新Claude翻译工作流的配置和提示词 重构工作流配置,简化权限设置并优化翻译逻辑。更新提示词以提供更清晰的翻译指令和格式要求,确保翻译结果的一致性。 * ci(workflows): 更新Claude工作流配置 添加track_progress选项以跟踪代码审查进度 补充环境信息变量和注释说明 * ci(workflow): 更新翻译工作流的触发条件和gh命令参数 修改工作流触发条件,仅当issue或comment不含翻译内容时执行 更新gh命令参数以使用正确的环境变量 * Revert "ci(workflows): 更新Claude工作流配置" This reverts commit 29f6a1dc8bf6682d735f4dfd6dac5f7fb9f9f079. * fix(ci): 修复GitHub Actions工作流中的条件判断和变量引用 修复工作流文件中的条件判断逻辑,添加括号确保正确执行 修复comment处理中的变量引用,使用正确的环境变量 添加注释说明Comment ID可能未定义的情况 * ci(workflow): 为翻译工作流添加并发控制 * ci(workflow): 仅协作者的issue或评论触发翻译工作流 * ci: 更新Claude翻译工具的allowed-tools和输出格式 更新Claude翻译工具的配置,添加mcp__github_comment__update_claude_comment到allowed-tools中 优化翻译输出的格式,使用Markdown的NOTE提示和折叠面板展示原始内容 * ci(workflow): 更新Claude翻译器的触发条件 将检测翻译标记从'**English Translation:**'改为'> [!NOTE]\n> This issue/comment was translated by Claude.' * fix(workflow): 简化Claude翻译器的触发条件检测 移除翻译标记中的Markdown注释格式,使检测更直接 * ci(workflow): 简化issues触发条件,仅响应opened事件 --------- Co-authored-by: 自由的世界人 <3196812536@qq.com> --- .github/workflows/claude-translator.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/claude-translator.yml b/.github/workflows/claude-translator.yml index fb1fb723b2..d5f7ea40d8 100644 --- a/.github/workflows/claude-translator.yml +++ b/.github/workflows/claude-translator.yml @@ -5,15 +5,15 @@ concurrency: on: issues: - types: [opened, edited] + types: [opened] issue_comment: types: [created, edited] jobs: translate: if: | - (github.event_name == 'issues' && github.event.issue.author_association == 'COLLABORATOR' && !contains(github.event.issue.body, '**English Translation:**')) || - (github.event_name == 'issue_comment' && github.event.comment.author_association == 'COLLABORATOR' && !contains(github.event.comment.body, '**English Translation:**')) + (github.event_name == 'issues' && github.event.issue.author_association == 'COLLABORATOR' && !contains(github.event.issue.body, 'This issue/comment was translated by Claude.')) || + (github.event_name == 'issue_comment' && github.event.comment.author_association == 'COLLABORATOR' && !contains(github.event.issue.body, 'This issue/comment was translated by Claude.')) runs-on: ubuntu-latest permissions: contents: read @@ -32,7 +32,7 @@ jobs: id: claude with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - claude_args: '--allowed-tools Bash(gh issue:*),Bash(gh api:repos/*/issues:*)' + claude_args: '--allowed-tools mcp__github_comment__update_claude_comment,Bash(gh issue:*),Bash(gh api:repos/*/issues:*)' prompt: | 你是一个多语言翻译助手。请完成以下任务: @@ -43,13 +43,16 @@ jobs: 3. 格式要求: - 标题:英文翻译(如果非英文) - 内容格式: - **English Translation:** + > [!NOTE] + > This issue/comment was translated by Claude. + [英文翻译内容] --- - - **Original Content:** +
+ **Original Content:** [原始内容] +
4. 使用gh工具更新: - 根据环境信息中的Event类型选择正确的命令: