Skip to content
Latchkey

How to Build Only Changed Paths in CI for a Large Repo

An on.push.paths filter stops a workflow from running at all when nothing in its area changed, the cheapest possible skip.

The least work is work you never start. For a large repo, give each buildable area its own workflow with a paths filter so unrelated commits do not trigger it. This complements diff-based gating inside a job.

Steps

  • Give each area its own workflow file.
  • Add paths: globs for that area under push and pull_request.
  • Add a placeholder required check so branch protection still passes on skips.

Workflow

.github/workflows/api.yml
name: api
on:
  push:
    paths:
      - 'services/api/**'
      - '.github/workflows/api.yml'
  pull_request:
    paths:
      - 'services/api/**'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: cd services/api && npm ci && npm test

Gotchas

  • A required check that never runs blocks merges; add a trivial always-pass job as a stand-in.
  • paths filters do not fire on schedule or workflow_dispatch, so those still run everything.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →