Repository navigation
fix(templates): build Next.js outside the deploy job that can mint a deploy token - #151
Open
dawsontoth wants to merge 3 commits into
Open
dawsontoth wants to merge 3 commits into
dawsontoth wants to merge 3 commits into
Conversation
…int a deploy token The Next.js deploy job installed dependencies and ran next build with id-token: write, so a compromised dependency's script could request the job's identity token and trade it for the deploy user's Harper token. The test job now builds and uploads .next (without .next/cache) as an artifact on main, and the deploy job downloads it after checkout and otherwise matches the shared deploy job: it installs only the Harper CLI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e a Windows checkout has CRLF Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kriszyp
approved these changes
Oct 18, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⊙ Problem
The Next.js templates' deploy job installed dependencies and ran
next buildwhile holdingid-token: write. Any dependency's install or build script could ask GitHub for the job's identity token and trade it for the deploy user's Harper token, which can deploy any app on the cluster.🤔 Is building in CI still right for Next.js?
Yes, for now: building on the cluster fails (HarperFast/nextjs#57, HarperFast/nextjs#58). Once those land, these templates can join the shared workflow and drop the artifact.
💡 Solution
next build, on pull requests too. Onmainit uploads.next, without.next/cache, as an artifact.persist-credentials: false.⚖️ Alternatives
buildjob — a second dependency install, and no isolation the test job doesn't already have..next/cachetoo — 20 of the 26 MB in a fresh scaffold, and the app serves without it.🤔 Should the build see production-environment variables?
It no longer can:
next buildruns outsideenvironment: production, so variables scoped to that environment don't reach it. The template uses none; a project that needsNEXT_PUBLIC_*values at build time can pass repository variables to the Build step withenv:.🔧 Changes
template-nextjs/_github/workflows/deploy.yamlandtemplate-nextjs-ts/_github/workflows/deploy.yamlare identical. The header comment says where the build runs. The test job builds and uploads it onmain, with hidden files on, since upload-artifact skips.nextotherwise, andoverwriteso a whole-workflow re-run can upload again. The deploy job downloads it and drops its install and build. TS copy: build, upload, download.template-nextjs/README.mdandtemplate-nextjs-ts/README.md: pull requests now build, and the deploy section says where the build runs and why. TS copy: build, deploy.templates-shared/applySharedTemplates.js: the comment on why the Next.js templates keep their own workflow.✅ Verification
npm test: 384 pass;lint:checkandformat:checkclean. Intemplate.tests/deployWorkflow.test.js, a new test checks that no template's deploy job installs dependencies or builds, and new Next.js tests check the upload, the download's order and that the deploy job matches the shared one apart from the download. The scaffolded pnpm workflow keeps pnpm out of the deploy job, and the helpers moved to module scope for these. 8 of them fail onmain.nextjs, rannpm run build, copied the project withoutnode_modulesand.next, added.nextwithoutcache/, and ranharper deploy project=nextsmoke restart=trueagainst a throwaway Harper 5.3.2. It deployed, andGET /returned 200 with the Harper-backed counter.Related: HarperFast/documentation#731 (the same fix in the CI guide's Path B), HarperFast/skills#119 (the skill rule that quotes the guide).
🤖 Generated by Claude Code (Claude Opus 5.5); posted via @dawsontoth.
Related PRs: #147 overlaps (merged; this hardens its Next.js deploy job)
Complexity: medium
Review-Coverage: authored=claude; ran=gemini,codex; adjudicated=domain; declined=cursor-grok,cursor-composer,cursor-kimi,cursor-muse,muse; rounds=1; full=1 @ 98f4fdc
Review-Attention: read ~3m (decisions: build-env-scope, duplicated-deploy-gate, pr-builds) @ 98f4fdc