# Run only when certain paths change

> Start a pipeline only when files you care about change, and run each job only for the part that changed.
> **Available** in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its `.forge-ci.yaml` or `.xeonr-ci.yaml`. See [What is available](https://docs.branchd.run/branchd/pipelines#what-is-available).

```yaml title=".branchd/pipelines/ci.yaml"
# .branchd/pipelines/ci.yaml
# The pipeline runs only when something under api/ or web/ changes; each
# job then runs only for the part that changed.
name: CI
on:
  push:
    branches: [main]
    paths: ['api/**', 'web/**', '!**/*.md']
  pull_request:
    paths: ['api/**', 'web/**', '!**/*.md']
jobs:
  api:
    if: changed('api/**')
    image: golang:1.26
    steps:
      - run: go test ./...
        working-directory: api
  web:
    if: changed('web/**') && exists('web/package.json')
    image: node:24
    steps:
      - run: npm ci && npm test
        working-directory: web
```

- **`paths:`** under `push` or `pull_request` starts the pipeline only when a
  changed path matches. Without a match, the file has no run for that commit,
  and `plan` says why.
- **Globs.** `*` matches within one path segment and `**` across segments;
  `?`, `[…]` and `{a,b}` work too. A leading `!` excludes, and the last
  pattern that matches decides: `'!**/*.md'` after `'api/**'` drops
  Markdown changes under `api/`.
- **`changed('glob', …)`** in an `if:` is true when any changed path matches.
- **`exists('glob', …)`** is true when a file of the commit matches.
- **Everything counts as changed** for a new branch, a tag, and a push with
  more changes than branchd lists. `paths` is not read for a tag.
- **Quote globs** that start with `*`, `!` or `{`: YAML reads those
  characters itself.

Do not require a check from a pipeline filtered by `paths:`: on a pull
request that changes nothing it matches, the check never reports, and the
pull request cannot merge. See
[Several pipelines in one repository](https://docs.branchd.run/branchd/pipelines/several-pipelines).

Source: https://docs.branchd.run/branchd/pipelines/paths
