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 testGotchas
- 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
How to Avoid CI Runs on Docs-Only ChangesPrevent GitHub Actions from spending minutes on documentation-only commits with paths-ignore, while keeping r…
How to Skip Duplicate Runs With ConcurrencyCancel superseded GitHub Actions runs with a concurrency group and cancel-in-progress, so rapid pushes to a b…