2.3 KiB
2.3 KiB
Splitting a workflow cluster out of a monorepo (n8n JSON repos)
- Map the cluster. Load every
*.jsonexport, collectexecuteWorkflownodes (target id/name) and webhook paths, then search the other exports for the cluster's ids/names to find callers. Read the repo's workflow index/catalog anddeploy/workflows.json(file -> n8n id). - Find hidden file dependencies. grep the tests/scripts for
readFileSync/loadWorkflowstring literals. Tests often load shared gateway exports (e.g. KAN, KNOW) and even unrelated config files (e.g. a LiteLLM config). Those cannot stay behind or the tests fail. - Ask scope questions before touching anything: shared dependencies (stay + document vs. copy), what happens to the original (default: later separate PR), keep history, repo name and visibility. If a question is skipped, take the recommended default and say so.
- Extract with history:
pip3 install --user git-filter-repo(binary lands in~/Library/Python/<ver>/binon macOS; add to PATH). Work ingit clone --no-local --single-branch --branch main <local clone>. Use--pathfor exact files (umlaut names work) and--path-regexfor test/doc families. Do not filter in the original clone. - Make it standalone:
- Put read-only snapshots of shared exports in
external/(NOT the repo root: auto-deploy actions deploy root*.json). Rewrite the test path literals toexternal/..., add a README there with the source commit SHA and a sync script. - Reduce
deploy/workflows.jsonto the cluster, keep the n8n ids unchanged (the workflows keep running in n8n; only the source changes). - Copy deploy script + its tests, CI workflows, and a test runner script. Legacy exports go to
legacy/. - Exclude CLI-style tests that need arguments/network from the runner.
- Write README, AGENTS.md and a dependencies doc (callers, callees, ids, webhook paths, env). Verify every claim in it against the JSON (a note mentioning a workflow is not a call).
- Put read-only snapshots of shared exports in
- Verify: run
node scripts/n8n-workflows.mjs validateand all tests; compare any failing test with the original repo before blaming the move. - Pitfalls: while both repos hold the same export, only one may auto-deploy or they overwrite each other in n8n; new repo needs its own
N8N_BASE_URL/N8N_API_KEYsecrets; move the finished repo out of the scratch dir (pruned after 24h).