A monorepo needs different pipelines per service, only when that service changes.

IntermediateScenarioGitLab CI
Answer

Situation read → Dynamic or child pipelines.

What I'd do →

  1. Use rules:changes with paths: and compare_to: refs/heads/main.
  2. For each service trigger a child pipeline: trigger: include: services/api/.gitlab-ci.yml.
  3. For very dynamic cases, generate YAML in one job and run it via trigger: include: artifact: ci.yml, job: generate.

Why → Child pipelines keep each service's config small and isolated.

Interview tip → rules:changes on branch pipelines without compare_to always evaluates true on new branches.

All CI/CD questions Roadmap: GitLab CI/CD

More on GitLab CI