Repository navigation
Zeta 运维:部署流程不自动应用 D1 迁移(靠人工 POST /api/admin/setup) - #256
Merged
todosdev[bot] merged 3 commits intoNov 29, 2026
Merged
Conversation
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.
Summary
*.workers.dev调POST /api/setup,迁移幂等、失败 fail closed——不再依赖管理员手动跑POST /api/admin/setup。POST /api/setup新增X-Setup-Secret请求头通道(保留 JSON body 兼容/setup页面),与部署自动升级步对齐。LIVY_JARS_DIR(默认/data/jars、普通 Variable 非密钥、需重跑部署),并同步部署流程与 Step 5 兜底口径。Changes
.github/workflows/deploy.yml:wrangler deploy之后新增Apply D1 migrations步骤。.github/scripts/apply-migrations.mjs(新增):解析worker/src/lib/migrations.ts的迁移名 → 查/开账号 workers.dev 子域 →POST /api/setup(X-Setup-Secret)→ 网络/429/5xx 退避重试、403 立即失败 → 断言响应migrations含本次源码全部迁移名,任一不满足::error::+exit 1。.github/workflows/ci.yml:Test deploy checks改为node --test .github/scripts/(覆盖新增脚本测试)。worker/src/routes/setup.ts:POST /api/setup接受X-Setup-Secret头(常量时间比较),body 形式保留给/setup页面。.github/scripts/test-apply-migrations.mjs(新增):deploy 新步骤的 secrets 接线与脚本调用回归。worker/src/routes/__tests__/setup.test.ts:新增 header 路径成功 + 错误 header 两个用例。README.md/README_zh-CN.md/CLAUDE.md:补LIVY_JARS_DIR到可选变量清单(与ALLOW_APP_DB_AS_TARGET并列);Step 4 增加第 5 条自动迁移;Step 5 改为「手动兜底」并删除「部署后仍应手动调用一次」旧口径。Testing
node --test .github/scripts/→ 7 通过。cd worker && pnpm vitest run --exclude '**/*-live.test.ts'→ 56 文件 / 1109 用例通过(全量跑仅*-live用例因缺外部服务失败,属既有环境依赖)。cd worker && pnpm exec tsc --noEmit→ 通过。7fab9a2)→Validate全绿。/api/setup(无生产凭据,且不应在评审/构建中对真实库写入)。