Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/fast-deploy-webhook.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
15 changes: 10 additions & 5 deletions internal/deploy/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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).
Expand Down
13 changes: 10 additions & 3 deletions internal/deploy/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading