fix(ci): skip npm publish for fork PRs so artifact still builds - #288
ranxianglei wants to merge 1 commit into
Conversation
GitHub passes no base-repo secrets to pull_request runs coming from forks, so NODE_AUTH_TOKEN is empty and 'npm publish' exits ENEEDAUTH on every fork contribution. The failing step aborts the job before 'npm pack', the artifact upload and the install-instructions comment run, so fork PRs lose their build artifact entirely. Guard the publish step with 'if: github.event.pull_request.head.repo.full_name == github.repository' so fork PRs skip only the publish and still produce the tarball, the Actions artifact and the PR comment. Owner-branch PRs are unchanged.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-288Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr288.tgz
npm install ./packageThis comment is automatically updated on each push. |
[bot] 🏷 PR Review — #288 ✅ Recommend merge Diff cleanliness — Clean. Exactly one added line on the Bug verification (triage — reproduced, not just reported)
Root cause vs. symptom — The symptom is "fork PRs lose their artifact." The root cause isn't in the workflow logic; it's GitHub's security model: Why this fix is sound —
Out-of-scope note — Agree with the author: the bot comment's "Option A — npm tag" line is moot for fork PRs until someone publishes manually; leaving it as-is is the right call. Not a blocker. No blocking issues, nothing to fix on the branch. Per repo policy, source changes need ≥2 agent reviews before merge and merging itself is human-only — I have not merged. 中文摘要: 修复了 fork PR 因拿不到 |
Problem
pr-artifact.ymlrunsnpm publish --tag pr-NwithNODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}beforenpm pack, the artifact upload and the install-instructions comment. Forpull_requestruns coming from a fork, GitHub passes no base-repo secrets (read-only token), soNODE_AUTH_TOKENis empty and publish exitsENEEDAUTH— on every fork contribution, e.g. #287. The failing step aborts the job, so fork PRs lose the tarball, the Actions artifact and the PR comment entirely.The job is not in master's required-check list (
test (22),test (24),pr-validation), so this never blocks merge — but it does block the artifact that fork contributors use to test pre-merge.Change
One line: guard the publish step so it only runs when the PR head is in this repository:
Fork PRs now skip only the publish step and still get
npm pack+ artifact upload + install-instructions comment. Owner-branch PRs are unchanged.Notes
build-artifactrun for fix(prune,compress): never split a tool call/result pair or an assistant run across a fold #287 will produce its artifact (pull_request events use the base branch's workflow files).