Skip to content

ci: Run agent 不再注入 GH_TOKEN——评审署名回归 pullfrog[bot] - #137

Merged
eatmoreduck merged 3 commits into
masterfrom
ci/pullfrog-review-identity
Sep 26, 2026
Merged

eatmoreduck merged 3 commits into
masterfrom
ci/pullfrog-review-identity

Conversation

@eatmoreduck

@eatmoreduck eatmoreduck commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

为什么改

同是控制台 Auto-review 的 dispatch「Review #N」模式,panta-log(官方模板原样)的评审署名是 pullfrog[bot],本仓库却是 github-actions[bot]。逐项对照后差异有两处,都让 GITHUB_TOKEN 抢走了评审提交权:

  1. Run agent 步骤多塞了 env.GH_TOKEN: ${{ github.token }}
  2. job permissions 给了 issues: write + pull-requests: write——GITHUB_TOKEN 有评审写权限,action 就自己提交

panta-log 官方模板两处都没有:GITHUB_TOKEN 只能读代码,action 无路可走,只能由服务端(OIDC 认证)以 pullfrog[bot] App 身份提交评审。

改了什么

  • 【删除】Run agent 步骤的 env.GH_TOKEN(5ef8609)
  • 【修改】job permissions 收敛为 id-token: write + contents: read,与官方模板一致(e4ee4f3)
  • 【修改】文件头凭据模型 + 两处注释,记录实测对照结论
  • 【保留】Checkout 步骤的 GH_TOKEN(只读拉代码,与评审提交无关)、prompt 契约、progress_comments: disabled

怎么测的 + 一个机制说明

workflow_dispatch 的 workflow 定义取自 dispatch 的 ref(master)——第一轮在 PR #137 自身上的验证不算数(07:37 的评审跑的还是 master 上的旧文件,见 run 36227320805)。所以正确验证流程是:

  1. 合并本 PR(改动进入 master)
  2. 开一个后续测试 PR → Auto-review 照常派发 → 看该评审署名是否为 pullfrog[bot]

yaml.safe_load 已验证:job permissions 仅 contents + id-token,Run agent env 无 GH_TOKEN。

🤖 Generated with Claude Code

实测对照 panta-log(官方模板原样,评审署名 pullfrog[bot])与本仓库
(评审署名 github-actions[bot]):两仓库同为服务端 dispatch「Review #N」
模式、评审 body 结构完全一致,唯一差异是本仓库给 Run agent 步骤多设了
GH_TOKEN——action 于是用 GITHUB_TOKEN 提交评审,署名落到
github-actions[bot] 头上。删掉该 env,action 走 id-token OIDC 由服务端
以 pullfrog[bot] App 身份提交(Checkout 步骤的 token 不受影响)。

Co-Authored-By: Claude Code <noreply@anthropic.com>

@github-actions github-actions 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.

Caution

Merging this as-is breaks .github/workflows/pullfrog.yml. Removing the step's only env key leaves env: as an empty mapping (YAML null), which GitHub rejects with Invalid workflow file … Unexpected value '' — every auto-review dispatch would fail to parse before the agent even starts.

Reviewed changes

  • Dropped env.GH_TOKEN from the Run agent step — relies on the action's OIDC / App-token path so reviews are submitted as pullfrog[bot]; the token-free direction matches Pullfrog's documented model (id-token: write + ASKPASS git auth), with Checkout keeping its own GH_TOKEN.
  • Rewrote the header credential note and the step comment — records that github.token now belongs only to Checkout and warns against re-adding GH_TOKEN.

ℹ️ Header still says reviews post as github-actions[bot]

The file header at lines 5-6 still reads「评审结论以 github-actions[bot] 名义发 review」, which the change itself now contradicts (the new lines 23-24 say the opposite). It is outside every diff hunk, so it is not inline-annotated here — worth fixing in this same doc pass, since the whole point of the header edit is to stop the identity from drifting back.

Technical details
# Stale reviewer-identity sentence in `pullfrog.yml` header

## Affected sites
- `.github/workflows/pullfrog.yml:5-6` —「并自动填好 prompt,评审结论以 github-actions[bot] 名义发 review」describes the pre-change behavior.

## Required outcome
- The header states the reviewer identity this workflow now produces (`pullfrog[bot]`), or drops the identity claim entirely.

## Suggested approach
- Update the sentence to `pullfrog[bot]` and, optionally, cross-reference the step comment at line 85.

ℹ️ This PR cannot validate itself via its own auto-review

Pullfrog auto-review dispatches run against the default branch, so the review landing on this PR executes master's pullfrog.yml — the one that still sets GH_TOKEN. The run for this PR (Review #137 [jauax]) is pinned to head_sha 6db7fee on master, confirming the pre-change file is what runs. Expect the auto-review on this PR to stay github-actions[bot] even after this fix; the real check has to happen on a run dispatched after merge.

Technical details
# Verification plan runs the wrong workflow revision

## Affected sites
- PR body "怎么测的" —「本 PR 即验证载体…直接看本 PR 评审的署名」.
- `.github/workflows/pullfrog.yml` is only reachable via `workflow_dispatch`, so a PR merged ref never executes here.

## Evidence
- Workflow-run list: every auto-review run has `head_branch: master`; `Review #137` is at `head_sha 6db7fee` (master, pre-merge).
- `docs.pullfrog.com/pr-reviews.md`: "Pullfrog runs … are dispatched against your default branch — so the workflow run never attaches to the pull request."

## Required outcome
- Verify on a post-merge run: merge, then trigger a review on another PR (or a fresh `workflow_dispatch`) and confirm the review author is `pullfrog[bot]` (compare against #135, authored by `github-actions[bot]`).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash | 𝕏

Comment thread .github/workflows/pullfrog.yml Outdated
env:
GH_TOKEN: ${{ github.token }}
# 不放 provider key:凭据由 Pullfrog 服务端持有(见文件头「凭据模型」)
# 不要在这里设 GH_TOKEN(2026-09-26 实测对照 panta-log):设了 action

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Removing the only key leaves this step's env: with no entries, so the value is YAML null — and GitHub rejects an empty env: mapping with Invalid workflow file … (Line: 84, Col: 9): Unexpected value '', which invalidates the whole workflow. yaml.safe_load returning None confirms the null but not GitHub's grammar; delete the env: key entirely (the comments can move above the step).

Technical details
# Empty `env:` mapping invalidates the workflow

## Affected sites
- `.github/workflows/pullfrog.yml:84` — `env:` has only comment children (lines 85-90), so its value is `null`.

## Evidence
- `actionlint .github/workflows/pullfrog.yml` → `84:13: expecting a single ${{...}} expression or mapping value for "env" section, but found plain text node`.
- GitHub: an empty `env:` block is an invalid workflow file — `Unexpected value ''` (see openvinotoolkit/openvino#37043, which cites the same failure for an empty `env:` at the workflow level; the step-level grammar is identical).
- `yaml.safe_load(open('.github/workflows/pullfrog.yml'))` returns `None` for this step's `env`.

## Required outcome
- The `Run agent` step declares no `env` key at all; `Checkout` keeps its own `GH_TOKEN`.

## Suggested approach
- Delete line 84 and lift the three comments above the `uses:` / `with:` block; no behavior is lost because the step intentionally has no env vars.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Addressed in 2fec60f — the env: key is deleted (comments lifted to step level); actionlint now passes clean.

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Flash | 𝕏

第一轮实测(PR #137 自身)署名仍是 github-actions——原因是
workflow_dispatch 的定义取自 master ref,PR 内无法自验证;该轮结果不作数。
本 commit 把 job permissions 收敛为 panta-log 官方模板同款(id-token: write
+ contents: read):GITHUB_TOKEN 没有评审所需的写权限,action 只能由服务端
以 pullfrog[bot] App 身份提交。与删 GH_TOKEN 形成双保险。

Co-Authored-By: Claude Code <noreply@anthropic.com>

@github-actions github-actions 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.

Caution

The two new commits are correct in direction, but this PR still cannot merge — the previous review's blocker remains unaddressed: env: on the Run agent step (.github/workflows/pullfrog.yml:87) has only comment children, so it parses to YAML null and GitHub rejects the workflow (Invalid workflow file … Unexpected value ''), which fails every auto-review dispatch before the agent starts. The existing thread carries the fix; do not merge until the env: key is deleted.

Reviewed changes

  • Trimmed the agent job's permissions to id-token: write + contents: read — dropped issues: write / pull-requests: write; verified against Pullfrog's documented contract (docs.pullfrog.com/headless-action, "Required permissions") that the action mints its own App installation tokens via OIDC and needs nothing further from GITHUB_TOKEN.
  • Rewrote the header credential note — now names pullfrog[bot] as the reviewer identity and records that PR-internal auto-review runs execute master's copy of the workflow, so the identity change is only verifiable post-merge.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash | 𝕏

eatmoreduck added a commit that referenced this pull request Sep 26, 2026
删掉 env: 键(纯注释子节点解析为 null,GitHub 拒载,#137 评审 blocker),
GH_TOKEN 禁设说明上移为步骤级注释并补记这个坑。
删掉 env: 键(纯注释子节点解析为 null,GitHub 拒载,#137 评审 blocker),
GH_TOKEN 禁设说明上移为步骤级注释并补记这个坑。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@eatmoreduck
eatmoreduck force-pushed the ci/pullfrog-review-identity branch from 469c43b to 2fec60f Compare September 26, 2026 08:04
@eatmoreduck

Copy link
Copy Markdown
Collaborator Author

blocker 已修(2fec60f):env: 键整个删除(纯注释子节点解析为 null 会被 GitHub 拒载,评审指得对——且 PR 内 CI 跑的是 master 上的旧定义,绿不证明新 yml 能载入),GH_TOKEN 禁设说明上移为步骤级注释并补记了这个坑。等本 PR 合并后按描述里的流程开测试 PR 验证署名。

@github-actions github-actions 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.

✅ No new issues found.

Reviewed changes

  • Deleted the env: key from the Run agent step — the previous review's blocker is fixed: a comment-only env: parsed to YAML null and invalidated the whole workflow. The comments are lifted to step level and a note warns against re-creating the pattern. Verified with yaml.safe_load (no env key) and actionlint 1.7.7 (exit 0, no findings).

Pullfrog  | View workflow run | Using DeepSeek Flash | 𝕏

@eatmoreduck
eatmoreduck added this pull request to the merge queue Sep 26, 2026
Merged via the queue into master with commit ddf742a Sep 26, 2026
1 check passed
Zhibin88 pushed a commit to Zhibin88/jev-chat-jarvis-mac that referenced this pull request Oct 13, 2026
…ev-chat#138)

本 PR 同时是 jev-chat#137 评审署名修复的验证载体:合并后 master 已是收敛版
pullfrog.yml,本 PR 的 Auto-review 评审应署名 pullfrog[bot](而非
github-actions[bot])。

Co-authored-by: Claude Code <noreply@anthropic.com>
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