Skip to content

ONE-253: deploy via --secrets-file + .dev.vars.example + var provenance - #142

Merged
mapxn merged 2 commits into
mainfrom
agent/daniel/076a644b1488
Oct 25, 2026
Merged

mapxn merged 2 commits into
mainfrom
agent/daniel/076a644b1488

Conversation

@mapxn

@mapxn mapxn commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

ONE-253 — 运行时密钥 CI 化(--secrets-file)+ .dev.vars.example + 出处登记

按父单 ONE-249 冻结契约实现,全部改动为 CI/文档,不改应用代码(env 读法不变)。

改动文件

  • .github/workflows/deploy.yml
    • Deploy 前新增 Write secrets file 步骤:把 JWT_SECRET / TOTP_ENCRYPTION_KEY / SETUP_SECRET 三个 GitHub Secret 写入 $RUNNER_TEMP/secrets.json(node 生成,mode 0600 并 chmod 600);写入前逐个校验非空,缺一立即 ::error:: 点名并中止(失败关闭),绝不用空值覆盖 CF 现有 Secret。
    • Deploy 步骤改为 pnpm run deploy -- --secrets-file "$RUNNER_TEMP/secrets.json",随部署上传为 Cloudflare Secret。
    • 红线遵守:不生成/替换密钥值,secrets.json 只落在 $RUNNER_TEMP、不写仓库工作区。
  • apps/worker/.dev.vars.example(新增):只列 7 个键名、值为空,无真实密钥。
  • CLAUDE.md / README.md / README.zh-CN.md:登记 APP_NAME / APP_URL / RP_ID / APP_ORIGIN 四个普通 var 出处(CF Dashboard 设置、本单不迁动),值严禁变更(RP_ID/APP_ORIGIN 关系 WebAuthn 通行密钥)。

自测证据

  • pnpm check:108 files,无错误
  • pnpm typecheck:2 tasks successful
  • pnpm build:2 tasks successful
  • pnpm test:85 pass / 0 fail
  • shellcheck .github/scripts/*.sh:exit 0
  • node --test .github/scripts/test-d1-migrations.mjs .github/scripts/test-deploy-checks.mjs:26 pass / 0 fail
  • Write secrets file 逻辑本地演练:secrets.json 三键正确、mode 600;缺 TOTP_ENCRYPTION_KEY 时 fail-closed 点名并 exit 1

未跑项:workflow 本身需在 GitHub Actions 上运行(无 CF 凭据/无法本地触发),已按本地脚本等价演练核心逻辑。

mapxn added 2 commits October 25, 2026 10:06
- deploy workflow: add fail-closed 'Write secrets file' step (JWT_SECRET /
  TOTP_ENCRYPTION_KEY / SETUP_SECRET -> $RUNNER_TEMP/secrets.json, mode 600,
  per-key non-empty check naming any missing secret); Deploy step passes
  --secrets-file so wrangler uploads them as Cloudflare Secrets.
- add apps/worker/.dev.vars.example listing the 7 keys with empty values.
- CLAUDE.md / README.md / README.zh-CN.md: register provenance for APP_NAME /
  APP_URL / RP_ID / APP_ORIGIN (CF dashboard only, not migrated, values immutable).
Per parent ONE-249 final decision: the CI secrets list contains exactly two keys
(JWT_SECRET, SETUP_SECRET), both fail-closed validated; TOTP_ENCRYPTION_KEY is
not referenced, validated, or written by the deploy workflow.
@mapxn
mapxn merged commit eb9b2ca into main Oct 25, 2026
2 checks passed
@mapxn
mapxn deleted the agent/daniel/076a644b1488 branch October 25, 2026 03:16
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