Skip to content
Latchkey

How to Cut CI Cost With Path Filters

A path filter is the cheapest optimization there is: a run that never starts costs zero minutes.

Add paths or paths-ignore to the push and pull_request events so each workflow only fires when files it cares about change.

Steps

  • Add paths: globs so a service builds only when its files change.
  • Use paths-ignore: to skip runs for docs-only or markdown edits.
  • Keep one filtered workflow per service in a monorepo.

Workflow

.github/workflows/api.yml
on:
  push:
    paths-ignore:
      - '**/*.md'
      - 'docs/**'
  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 gets skipped can block merges; pair it with a passing placeholder job.
  • Path filters apply to push and pull_request, not to schedule or workflow_dispatch.
  • paths and paths-ignore are mutually exclusive within a single event.

Related guides

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