ci: main 上的推送自动跑 bun test 并发布到 cplus.talkincode.net - #63
Merged
Merged
Conversation
站点曾经停在 4 节课,而仓库已经补到 40 节课——构建与部署只在某台机器上手工跑过一次, 之后没人重跑。这条链路现在由 CI 接手:main 上的推送先跑 bun test,通过后 bun run deploy 发布,最后抽检线上(每一节课、末尾斜杠跳转、词条面板、中文 404),任一步失败都会变红。 - .github/workflows/test-and-deploy.yml:push(main) / pull_request / workflow_dispatch; PR 上只跑测试,发布只在 main 上发生;同一时间只允许一次发布 - 凭据只从仓库 secret CLOUDFLARE_API_TOKEN 取;缺它时发布步骤明确失败, 不会静默跳过、把「没发布」伪装成绿色(账号 ID 不是凭据,写在仓库里) - tests/ci-workflow.test.ts:锁住触发条件、测试先于发布、发布只走 bun run deploy、 凭据来源、发布后的线上抽检覆盖 lessons/ 下每一节课,以及文档写清了 secret 名字 - README、docs/roadmap.md、docs/feature-checklist.md、AGENTS.md:把「发布是人工动作」 改写成「main 自动发布,人工只是兜底」
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.
站点曾经停在 4 节课,而仓库已经补到 40 节课——构建与部署只在某台机器上手工跑过一次,之后再没人重跑。上一轮已经把构建与发布链路收进仓库(#62),但发布仍然是人工动作:main 一合,线上就会悄悄落后。这个 PR 让 main 上的推送自动发布。
改动
.github/workflows/test-and-deploy.ymlpush到 main、pull_request、workflow_dispatch。test作业:actions/checkout@v7+oven-sh/setup-bun@v2(Bun 1.3.14)+bun test。deploy作业:needs: test,只在 main 上跑(PR 上没有 secrets,也不该发布);bun run deploy(内部先bun run build,不会把旧产物发出去);发布后抽检线上——遍历lessons/下每一节课(漏课正是这次事故的形态)、末尾斜杠跳转、词条面板、中文 404,失败重试三次。CLOUDFLARE_API_TOKEN取(权限Workers Scripts: Edit);账号 ID 不是凭据,写在仓库里,所以只需要配一个 secret。缺 secret 时发布步骤明确失败并给出添加路径,不会静默跳过、把「没发布」伪装成绿色。tests/ci-workflow.test.ts:在bun test里锁住这条工作流——触发条件、bun test先于发布且deploy依赖它、发布只走bun run deploy(出现直接的wrangler deploy会失败)、凭据来源与账号 ID 形态、发布后抽检覆盖lessons/下每一节课且域名与wrangler.jsonc一致、文档写清了 secret 名字。docs/roadmap.md(能力清单、验收矩阵行、维护规则)、docs/feature-checklist.md、AGENTS.md 里「发布是人工动作」的表述改为「main 自动发布,人工只是兜底」。验证
bun test:766 通过 / 0 失败(新增 6 项)。Bun.YAML.parse解析通过,每个run:脚本过bash -n。push触发):test作业会绿;deploy作业在仓库 secret 配好之前会红并说明怎么配——这是有意为之,比「绿色但没发布」诚实。