<!--
title: Optimize workflow triggers
domain: ml-systems
topic: CI/CD
language: Yaml
source: huggingface/tokenizers
updated: 2024-10-17
url: https://awesomereviewers.com/reviewers/tokenizers-optimize-workflow-triggers/
-->

Configure CI workflows with targeted triggers and path filters to balance thoroughness with efficiency. Run critical build jobs on every commit for affected components, while avoiding unnecessary builds when changes don't impact certain components.

For example, use path filters to only run specific workflows when relevant files change:

```yaml
name: Node Build
on:
  push:
    paths:
      - 'bindings/node/**'
      - 'src/**'
    paths-ignore:
      - '*.md'
      - 'docs/**'
  pull_request:
    paths:
      - 'bindings/node/**'
      - 'src/**'

jobs:
  build:
    # Build configuration here
```

Keep your CI components updated to their latest stable versions:
```yaml
- name: Install Python
  uses: actions/setup-python@v5  # Use latest stable version
```

Consider workflow organization - separate workflows by component or purpose, but look for opportunities to consolidate setup steps and reuse configuration across similar jobs.
