dorny/paths-filter: Conditional Jobs by Changed Paths
paths-filter outputs which path groups changed so you can skip unrelated jobs.
Define named filters with path globs. The action sets a true/false output per filter you reference in if: conditions, ideal for monorepos.
Key inputs (with:)
- filters: YAML mapping of name to path globs.
- base: base ref to diff against.
- list-files: also output the changed file list.
- token: token for fetching the diff on PRs.
Example workflow
.github/workflows/ci.yml
jobs:
changes:
runs-on: ubuntu-latest
outputs:
api: ${{ steps.filter.outputs.api }}
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
api:
- 'api/**'
api:
needs: changes
if: ${{ needs.changes.outputs.api == 'true' }}
runs-on: ubuntu-latest
steps:
- run: echo "build api"On any runner
This action runs on any runner. Latchkey managed runners run it unchanged, and skipping unrelated jobs saves minutes.
Key takeaways
- Expose filter outputs from a job, then gate downstream jobs.
- Ideal for monorepos to avoid building everything.
- Use list-files when you need the actual changed paths.
Related guides
tj-actions/changed-files: List Changed Files in CIReference for tj-actions/changed-files: get the list of files added, modified, or deleted in a push or PR to…
actions/labeler: Auto-Label PRs by Changed PathsReference for actions/labeler: automatically apply labels to pull requests based on which files they touch, c…
actions/checkout: Inputs & Workflow UsageReference for actions/checkout: clone your repository into the runner, control fetch-depth, submodules, refs,…