Skip to content
Latchkey

How to Run Only on Changed Paths in GitHub Actions

A paths filter limits triggering to commits that touch the directories you care about.

Add paths: (or paths-ignore:) under the push/pull_request event. The workflow runs only when a changed file matches.

Steps

  • Add paths: globs under on.push and on.pull_request.
  • Use paths-ignore: for the inverse (docs-only changes).
  • Keep filters per workflow so each service builds independently.

Workflow

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

Gotchas

  • A skipped path-filtered required check can block merges; pair with a passing placeholder job.
  • paths filters apply to push and pull_request, not to schedule or dispatch.

Related guides

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