diff --git a/docs/fast-deploy-webhook.md b/docs/fast-deploy-webhook.md index a188ce6..4796b95 100644 --- a/docs/fast-deploy-webhook.md +++ b/docs/fast-deploy-webhook.md @@ -4,7 +4,7 @@ The operator turns a content-only git push into a Cloudflare KV content update ("fast deploy"), with **no** code redeploy. Flow: ``` -git push (main, content-only: .deco/blocks/** + src/server/cms/blocks.gen.json) +git push (main, content-only: .deco/blocks/** + .deco/blocks.gen.json) → GitHub webhook → operator POST /webhooks/github (HMAC-verified) → DeploymentTarget (cloudflare-workers) resolves the repo's Deco CR, creates/updates a Decofile CR (target: tanstack-kv) @@ -86,8 +86,10 @@ or non-content changes — or per repo (Settings → Webhooks). Either way: The operator processes only pushes to the repo's default branch whose changed files are **all content paths**: under `.deco/blocks/**` or the regenerated bundled snapshot -`src/server/cms/blocks.gen.json` (Studio commits both together). Any other changed -file makes it a code push → normal build path. A `ping` event (sent on setup) returns `200`. +`.deco/blocks.gen.json` (7.x `@decocms/blocks-cli`) / `src/server/cms/blocks.gen.json` +(legacy `@decocms/start@6`) — Studio commits the blocks + the snapshot together. Any +other changed file makes it a code push → normal build path. A `ping` event (sent on +setup) returns `200`. ## 4. Verify diff --git a/internal/deploy/target.go b/internal/deploy/target.go index 6954cbd..7a8ca3b 100644 --- a/internal/deploy/target.go +++ b/internal/deploy/target.go @@ -26,10 +26,15 @@ import ( const ( // blocksPrefix is the repo-relative directory holding the decofile blocks. blocksPrefix = ".deco/blocks/" - // blocksGenFile is the bundled snapshot Studio regenerates alongside a - // content commit (used for HMR). It is derived from .deco/blocks, so its - // presence in a diff carries no code change. - blocksGenFile = "src/server/cms/blocks.gen.json" + // blocksGenFile is the bundled snapshot regenerated alongside a content + // commit (used for HMR). It is derived from .deco/blocks, so its presence + // in a diff carries no code change. 7.x (@decocms/blocks-cli) emits it at + // .deco/blocks.gen.json. + blocksGenFile = ".deco/blocks.gen.json" + // blocksGenFileLegacy is the pre-7.x location (@decocms/start@6, emitted + // under src/server/cms/). Kept so sites not yet on the split packages still + // fast-deploy content-only commits. + blocksGenFileLegacy = "src/server/cms/blocks.gen.json" ) // PushEvent is the normalized git push the webhook hands to a DeploymentTarget. @@ -100,7 +105,7 @@ func isContentOnly(files []string) bool { // isContentPath reports whether a single changed file counts as content. func isContentPath(f string) bool { - return strings.HasPrefix(f, blocksPrefix) || f == blocksGenFile + return strings.HasPrefix(f, blocksPrefix) || f == blocksGenFile || f == blocksGenFileLegacy } // maxNameLen is the Kubernetes object-name ceiling (DNS-1123 label). diff --git a/internal/deploy/target_test.go b/internal/deploy/target_test.go index 46d5af1..84385ae 100644 --- a/internal/deploy/target_test.go +++ b/internal/deploy/target_test.go @@ -10,16 +10,23 @@ func TestIsContentOnly(t *testing.T) { }{ {"empty list is not content", nil, false}, {"blocks only", []string{".deco/blocks/pages-home.json"}, true}, - {"gen snapshot only", []string{"src/server/cms/blocks.gen.json"}, true}, - {"blocks + gen snapshot (studio commit)", []string{ + {"gen snapshot only (7.x .deco)", []string{".deco/blocks.gen.json"}, true}, + {"gen snapshot only (legacy src/server/cms)", []string{"src/server/cms/blocks.gen.json"}, true}, + {"blocks + gen snapshot (7.x studio commit)", []string{ ".deco/blocks/pages-home.json", ".deco/blocks/loaders-products.json", + ".deco/blocks.gen.json", + }, true}, + {"blocks + gen snapshot (legacy studio commit)", []string{ + ".deco/blocks/pages-home.json", "src/server/cms/blocks.gen.json", }, true}, {"mixed with code", []string{".deco/blocks/pages-home.json", "src/components/Header.tsx"}, false}, {"code only", []string{"src/components/Header.tsx"}, false}, {"sibling dir does not match prefix", []string{".deco/blocks-old/x.json"}, false}, - {"other gen files are code", []string{"src/server/cms/sections.gen.ts"}, false}, + {"legacy sibling gen files are code", []string{"src/server/cms/sections.gen.ts"}, false}, + {"other .deco gen files are code (7.x)", []string{".deco/sections.gen.ts"}, false}, + {"other .deco gen files are code (7.x meta)", []string{".deco/meta.gen.json"}, false}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) {