Skip to content

fix(ci): token 交给 github-script 本身,不再 require @actions/github(第三次,也是最后一层) - #4578

Merged
os-zhuang merged 2 commits into
mainfrom
claude/fix-cross-repo-closer-require
Aug 2, 2026
Merged

fix(ci): token 交给 github-script 本身,不再 require @actions/github(第三次,也是最后一层)#4578
os-zhuang merged 2 commits into
mainfrom
claude/fix-cross-repo-closer-require

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

失败

Error: Cannot find module '@actions/github'
Require stack:
- /home/runner/work/_actions/actions/github-script/v9/dist/index.js

github-script 把依赖打包进了自己的 bundle,script: 块里 require('@actions/github') 解析不到

改法:根本不需要第二个客户端

把 token 交给 action 本身,注入的 github 就是跨仓库客户端:

github-token: ${{ secrets.CROSS_REPO_ISSUE_TOKEN || secrets.GITHUB_TOKEN }}

回退到 GITHUB_TOKEN 是必要的:没有跨仓库凭据时,report 路径仍要能在本 PR 上留言。

#4573 的关系

本 PR 取代 #4573 #4573 把第二个客户端从 octokit 改名为 crossRepo,修掉了解析期的标识符冲突——正因为如此,运行才第一次走得够远,撞上了这个解析不到的模块。本 PR 直接删掉那个客户端,冲突与模块问题一并消失。

#4573 若已合入 main,本 PR 覆盖同一区域;若出现冲突,以本 PR 为准。

三次运行,每次都更深一层

运行 失败点 阶段
objectstack #4553 合并 SyntaxError: Identifier 'octokit' has already been declared 解析
objectui #3179 合并 Cannot find module '@actions/github' 模块解析
预期下一次 —— API 调用(尚未到达)

这三次每一次都由真实运行发现,没有一次是静态检查发现的。 静态检查此前给过两次绿灯,而它回答的问题始终比运行时窄一层:第一次的包装漏了注入标识符,第二次的包装则根本不模拟模块解析。

一个已被证实有效的副产物

objectui 那次运行确认了凭据日志有用:

CROSS_REPO_ISSUE_TOKEN: configured
Cross-repo targets: objectstack-ai/objectstack#4475

第一行回答了「secret 到底配没配」——在此之前这个问题无法回答,因为无跨仓库引用时任务会提前返回,配了和没配的日志完全一样。第二行说明关键字解析本身工作正常。

验证状态(如实)

状态
YAML 解析
脚本语法(含注入标识符全集的包装)
脚本内已无 require('@actions/github')(仅注释提及)
凭据日志有效 已由 objectui 的真实运行证实
关键字解析有效 已由同一次运行证实(命中 objectstack-ai/objectstack#4475)
关闭/评论的 API 调用路径 仍未实测 —— 三次运行都没走到这里

最后一行是老实话:这个工作流的 API 调用部分一次都没有真正执行过。 本 PR 合并会是第四次运行;若再失败,请以 Actions 日志为准,不要采信本表。

配套修复已推到 objectui 的对应分支。


Generated by Claude Code

…ing @actions/github

`require('@actions/github')` is not resolvable from a github-script `script:`
block — the action bundles its dependencies, so it dies with MODULE_NOT_FOUND.
Passing the token via `github-token:` makes the injected `github` client the
cross-repo one, so no second client is needed at all.

Observed in objectui, whose copy reached that line first. Supersedes the rename
in #4573: that fixed the parse-time collision, which is what let the run get
far enough to hit this.
@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 2, 2026 8:43am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci/cd tooling size/s labels Aug 2, 2026
@os-zhuang
os-zhuang enabled auto-merge August 2, 2026 08:36
…-closer-require

# Conflicts:
#	.github/workflows/cross-repo-issue-closer.yml
@os-zhuang
os-zhuang added this pull request to the merge queue Aug 2, 2026
Merged via the queue into main with commit d91d39e Aug 2, 2026
17 checks passed
@os-zhuang
os-zhuang deleted the claude/fix-cross-repo-closer-require branch August 2, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd documentation Improvements or additions to documentation size/s tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants