diff --git a/docs/reference/g14-gitops-cicd.md b/docs/reference/g14-gitops-cicd.md index 11f45ac7..0b3dbcc9 100644 --- a/docs/reference/g14-gitops-cicd.md +++ b/docs/reference/g14-gitops-cicd.md @@ -19,6 +19,7 @@ G14 是 HWLAB 当前 DEV/PROD 原生 k8s 与 GitOps 运行面目标。G14 CI/CD - 直接声明 Tekton Pipeline、最小原语校验 task 和 PipelineRun 样板;不再读取 `CI.json` 或生成 `ci-json` step。 - 读取 `deploy/deploy.json` 与 `deploy/k8s/*`,生成 Argo CD 可消费的 G14 runtime Kustomize path。 - G14 Tekton 的镜像构建发布入口必须是 `scripts/g14-artifact-publish.mjs`;它只是集群内 Task 的 build/push helper,不做 rollout、不写 D601、不获取 legacy DEV CD Lease。旧 `scripts/dev-artifact-publish.mjs` 入口已删除;`dev-cd-apply`、`ci-publish` 和旧 `main` JS CD 入口禁止出现在 G14 Pipeline 生成脚本和 G14 验收证据中。 +- `g14-contract-check` 在 source branch 上校验的是仓库中已提交 `deploy/gitops/g14/source.json` 记录的 `sourceCommit`;它用于防止 render 代码和已提交控制面产物失配,不把普通 `HEAD` 提交号变化本身当成 GitOps drift。面向当前提交的真实 render/promotion 发生在 `gitops-promote` step。 - 生成 `hwlab-g14-branch-poller` CronJob:它使用 G14 集群内的 Git SSH Secret 轮询 `G14` 分支,按 source commit 创建确定命名的 Tekton PipelineRun。 - 生成 `hwlab-g14-control-plane-reconciler` CronJob:它使用同一个 Git SSH Secret 轮询 `G14`,运行 repo 内 `scripts/g14-gitops-render.mjs`,并 server-side apply 生成的 Tekton RBAC、Pipeline、Poller 和 Reconciler manifests;因此 CI 控制面变化应自动进入 G14 k3s,不需要人工长期执行 render/apply。 - 默认输出到 `deploy/gitops/g14/`。 diff --git a/scripts/g14-gitops-render.mjs b/scripts/g14-gitops-render.mjs index 8acab297..df750853 100644 --- a/scripts/g14-gitops-render.mjs +++ b/scripts/g14-gitops-render.mjs @@ -58,7 +58,9 @@ const primitiveValidationTasks = Object.freeze([ name: "g14-contract-check", commands: [ "node --check scripts/g14-gitops-render.mjs", - "node scripts/g14-gitops-render.mjs --check", + "render_check_revision=$(node --input-type=module -e \"import fs from 'node:fs'; const data = JSON.parse(fs.readFileSync('deploy/gitops/g14/source.json', 'utf8')); process.stdout.write(data.sourceCommit);\")", + "test -n \"$render_check_revision\"", + "node scripts/g14-gitops-render.mjs --check --source-revision \"$render_check_revision\"", "node --check scripts/artifact-publish.mjs", "node --check scripts/g14-artifact-publish.mjs" ]