Skip to content

ci: add automatic Codex and Claude PR reviews#11

Merged
thun-res merged 7 commits into
masterfrom
add-claude-github-actions-1784813677573
Jul 23, 2026
Merged

ci: add automatic Codex and Claude PR reviews#11
thun-res merged 7 commits into
masterfrom
add-claude-github-actions-1784813677573

Conversation

@thun-res

@thun-res thun-res commented Jul 23, 2026

Copy link
Copy Markdown
Owner

概述

将原先由 github-actions[bot] 发送 @codex review 的不可靠方案,替换为自动且权限受控的 Codex + Claude PR 审查:

  • Codex 使用仓库原生 Automatic reviews;该集成已经在本 PR 上成功触发。
  • Claude 使用官方 anthropics/claude-code-action,在 PR 新建、更新、转为 Ready 或重新打开时运行。
  • Codex 与 Claude 的审查摘要、问题、影响和修复建议均要求使用简体中文。
  • 在 PR 新建或转为 Ready 时,由 github-actions[bot] 发布中文启动提示;不会再发送无效的 Bot 身份 @codex review
  • Claude 可发布顶层总结和行内建议,但不能修改或推送仓库文件。
  • 草稿、外部 Fork、Bot 和 Dependabot PR 会安全跳过需要 Secret 的 Claude 作业。
  • 同一 PR 的旧审查运行会在新提交到达时自动取消。
  • 删除旧的 Codex 请求脚本、邮件通知脚本和重复的 Claude 工作流。

安全与可靠性

  • 所有外部 Action 均固定到已验证的完整提交 SHA,避免可移动标签带来的供应链风险。
  • Claude 作业使用最小权限:contents: readpull-requests: writeid-token: write
  • Checkout 不持久化 Git 凭据。
  • Claude 最长运行 30 分钟、最多 10 个 agent turns。
  • PR 内容按不可信数据处理;Claude 仅允许查看当前 PR,以及发布当前 PR 的顶层/行内评论。
  • 关闭英文进度评论和默认英文 “Fix this” 链接。

认证

  • Codex:仓库原生 Automatic reviews,不在 GitHub Actions 中保存 OpenAI API Key。
  • Claude:仓库 Secret CLAUDE_CODE_OAUTH_TOKEN,由 Claude 官方安装流程写入。

验证

  • git diff --check
  • YAML lint
  • actionlint
  • GitHub Script JavaScript 语法检查
  • zizmor GitHub Actions 安全审计
  • GitHub 实际运行确认固定 SHA、输入参数和权限均被正确解析

运行说明

Claude 官方 Action 会拒绝在尚未进入默认分支、或被 PR 修改过的工作流文件上执行模型,这是其安全校验的预期行为。因此本 PR 中 Claude 步骤会安全跳过并返回成功;合并后,后续同仓库的人类作者 PR 才会进行完整 Claude 模型审查。Codex 继续使用其原生触发条件。

@github-actions

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7679201a8c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

id: claude-review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip fork PRs that cannot receive the OAuth secret

For a pull request originating from an external fork, GitHub does not expose repository secrets to a pull_request workflow, so this input is empty and the automatic review action fails authentication. Since the workflow currently runs for every PR, guard the job with a same-repository check or otherwise avoid starting the secret-dependent action for fork PRs.

Useful? React with 👍 / 👎.


on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cancel superseded review runs per pull request

When multiple commits are pushed to a PR before the preceding Claude run completes, each synchronize event starts an independent review with no per-PR concurrency group. The older run can therefore consume another review and publish feedback based on a superseded checkout after the newer run; add PR-number-based concurrency with cancel-in-progress as used by the existing AI review workflow.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/claude.yml Outdated
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid replaying old mentions on every issue assignment

For an issue whose title or body contains @claude, every subsequent assigned event satisfies the same condition even when the new assignee is an unrelated maintainer and no new Claude request was made. An issue opened with the mention therefore runs once for opened and again whenever its assignees change, potentially duplicating work, comments, branches, and API usage; remove this event or restrict it to the intended Claude assignee.

Useful? React with 👍 / 👎.

@thun-res thun-res changed the title Add Claude Code GitHub Workflow ci: add automatic Codex and Claude PR reviews Jul 23, 2026
@thun-res
thun-res merged commit ed7d9f0 into master Jul 23, 2026
6 checks passed
thun-res added a commit that referenced this pull request Jul 23, 2026
Port the reviewed changes from PR #11 onto the dev branch.
@thun-res
thun-res deleted the add-claude-github-actions-1784813677573 branch July 23, 2026 14:17
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