How to Set Up a Monorepo Pipeline in CircleCI
CircleCI handles monorepos with a setup workflow: the path-filtering orb sets parameters from changed files, then continues to a generated config.
Enable setup workflows, use the path-filtering orb to map changed paths to pipeline parameters, then continuation runs the real config with only the affected parts enabled.
Path-filtering setup workflow
The setup config maps changed paths to parameters and continues to the main config.
.circleci/config.yml
version: 2.1
setup: true
orbs:
path-filtering: circleci/path-filtering@1
workflows:
setup:
jobs:
- path-filtering/filter:
base-revision: main
config-path: .circleci/continue.yml
mapping: |
packages/api/.* run-api true
packages/web/.* run-web trueGotchas
- The top-level
setup: trueflag and "setup workflows" must be enabled in project settings, or the filter is ignored. - The continued config (
continue.yml) reads the parameters and gates each workflow withwhen: << pipeline.parameters.run-api >>. base-revisioncontrols the diff base; on the default branch the diff may be empty, so handle the no-change case.
Related guides
How to Set Up a Monorepo Pipeline in GitHub ActionsSet up a monorepo pipeline in GitHub Actions that builds only changed packages, using a change-detection job…
How to Conditionally Run a Job in CircleCIConditionally run jobs and workflows in CircleCI with when/unless logic, filters:branches, and pipeline param…