Skip to content
Latchkey

How to Trigger Only on Changed Paths in GitHub Actions

A paths filter limits triggering to commits that touch files matching your globs, so each service builds only when its code moves.

Add paths: under the push or pull_request event to run only on matching changes, or paths-ignore: to skip changes that touch only certain files.

Steps

  • Add paths: under on.push with the directories that matter.
  • Use paths-ignore: instead to skip docs-only pushes.
  • Keep one workflow per service so each has its own filter.

Workflow

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

Gotchas

  • You cannot combine paths and paths-ignore in the same event; pick one and use negations.
  • A skipped path-filtered required check can block a merge; add a placeholder job that always passes.

Related guides

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