This action builds upon dorny/paths-filter, forked from commit de90cc6. Special thanks to Dorny and all contributors for laying the groundwork for this enhanced version.
A powerful GitHub Action that enables conditional execution of workflow steps and jobs based on the files modified by pull requests, feature branches, or recent commits.
โก Why Use This Action?
GitHub's built-in path filters don't work at the job or step level, making this action essential for conditional workflow execution.
- uses: santosr2/conditional-paths-action@v1
id: changes
with:
filters: |
src:
- 'src/**'
docs:
- 'docs/**'
- '*.md'
# Run only if source code changed
- name: Build and Test
if: steps.changes.outputs.src == 'true'
run: npm run build && npm test
# Run only if documentation changed
- name: Deploy Docs
if: steps.changes.outputs.docs == 'true'
run: npm run deploy:docs
This action supports dual Node.js compatibility to maximize compatibility across different environments:
Environment | Node.js Version | Status | Purpose |
---|---|---|---|
GitHub Actions Runtime | Node.js 24 | โ Primary | Action execution in workflows |
Local Development | Node.js 22 | โ Supported | Development and testing |
CI/CD Pipeline | Node.js 22 | โ Tested | Dependabot compatibility |
All workflows (CI, security scans, documentation generation, performance benchmarks, and SBOM generation) are validated on a Node.js 22/24 compatibility matrix. This ensures the action works reliably across both development and runtime environments.
Our CI pipeline runs comprehensive testing across:
fail-fast: false
ensures both versions are fully testedstrategy:
fail-fast: false
matrix:
node-version: [22, 24] # Full compatibility matrix
This approach provides maximum compatibility while leveraging the latest GitHub Actions runtime capabilities.
Name | Description | Required | Default |
---|---|---|---|
filters |
Path to YAML file or inline YAML string defining path filters | โ Yes | |
token |
GitHub token for API access (pull requests only) | โ No | ${{ github.token }} |
base |
Git reference to compare against | โ No | Repository default branch |
ref |
Git reference to detect changes from | โ No | ${{ github.ref }} |
working-directory |
Relative path where repository was checked out | โ No | |
list-files |
Output format for matched files: none , csv , json , shell , escape |
โ No | none |
initial-fetch-depth |
Initial number of commits to fetch for comparison | โ No | 100 |
predicate-quantifier |
Pattern matching mode: some (OR) or every (AND) |
โ No | some |
For each filter named {filter-name}
, the action provides:
Output | Type | Description |
---|---|---|
{filter-name} |
string |
'true' if any files match the filter, 'false' otherwise |
{filter-name}_count |
number |
Count of files matching the filter |
{filter-name}_files |
string |
List of matching files (when list-files is enabled) |
changes |
string |
JSON array of all filter names with matches |
This action requires specific permissions depending on the workflow trigger:
permissions:
pull-requests: read # Required for pull_request events
contents: read # Required for repository access
Note: For pull_request
workflows, only pull-requests: read
is required as the action uses the GitHub API for faster performance.
name: Conditional Workflow
on: [push, pull_request]
jobs:
detect-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: santosr2/conditional-paths-action@v1
id: changes
with:
filters: |
src: 'src/**'
docs: 'docs/**'
- name: Build if source changed
if: steps.changes.outputs.src == 'true'
run: npm run build
- name: Deploy docs if changed
if: steps.changes.outputs.docs == 'true'
run: npm run deploy-docs
name: Monorepo CI
on: [push, pull_request]
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
contents: read
outputs:
packages: ${{ steps.filter.outputs.changes }}
frontend: ${{ steps.filter.outputs.frontend }}
backend: ${{ steps.filter.outputs.backend }}
steps:
- uses: santosr2/conditional-paths-action@v1
id: filter
with:
filters: |
frontend: 'packages/frontend/**'
backend: 'packages/backend/**'
shared: 'packages/shared/**'
test-packages:
needs: changes
if: ${{ needs.changes.outputs.packages != '[]' }}
strategy:
matrix:
package: ${{ fromJSON(needs.changes.outputs.packages) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test ${{ matrix.package }}
run: npm test --workspace=${{ matrix.package }}
deploy-frontend:
needs: changes
if: needs.changes.outputs.frontend == 'true'
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: Deploy Frontend
run: npm run deploy:frontend
# Install act
brew install act # macOS
# or curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
# Build the action first
pnpm run package
# Test basic scenarios
act workflow_dispatch -W .github/workflows/examples/test-action-locally.yml
# Test specific jobs
act workflow_dispatch -W .github/workflows/examples/test-action-locally.yml -j test-basic-filters
# Test with verbose output for debugging
act workflow_dispatch -W .github/workflows/examples/test-action-locally.yml --verbose
# Use specific runner image for Node.js compatibility
act -P ubuntu-latest=catthehacker/ubuntu:act-22.04
For detailed local testing examples, see our examples directory and act-commands.md.
Complete documentation is available in our organized documentation structure:
Our documentation covers all aspects of using and contributing to this action:
Performance metrics and benchmarks are continuously monitored and available at /performance:
Performance is automatically tracked through:
This repository maintains the highest security standards with comprehensive automated scanning and transparent reporting:
Please report security issues through our Security Policy. Do not create public issues for security vulnerabilities.
We provide complete supply chain transparency through automatically generated SBOMs in industry-standard format:
A Software Bill of Materials (SBOM) is a comprehensive inventory of all components, libraries, and dependencies used in this action. It provides:
We use the industry-standard CycloneDX v1.4 format, compatible with:
The SBOM is automatically generated during our build process and updated with every release, ensuring complete accuracy and freshness.
Join our vibrant community for support, feature requests, and collaboration:
Our Discussions are organized into focused categories:
Category | Purpose | Use For |
---|---|---|
๐ก Q&A | Get help and support | Usage questions, troubleshooting, best practices |
๐ Ideas | Propose new features | Feature requests, enhancement suggestions |
๐ข Announcements | Stay updated | Release notes, important updates, roadmap |
๐ Show and Tell | Share your usage | Success stories, creative implementations, tutorials |
Track development progress and roadmap through our automated project board:
The board automatically syncs with:
We welcome contributions from developers of all skill levels! Please see our comprehensive CONTRIBUTING.md for guidelines.
This project uses mise for consistent toolchain management across development and CI environments:
# Clone the repository
git clone https://github.com/santosr2/conditional-paths-action.git
cd conditional-paths-action
# Install development toolchain (Node.js 22, pnpm 10)
mise install
# Install dependencies and setup pre-commit hooks
pnpm install
# Run the complete validation pipeline
pnpm run ci
Test your changes locally before submitting:
# Build and package the action
pnpm run package
# Run comprehensive test suite
pnpm run test:coverage # โฅ80% coverage required
# Test with act (local GitHub Actions runner)
act workflow_dispatch -W .github/workflows/examples/test-action-locally.yml
# Run performance benchmarks
pnpm run bench
Thanks to all the amazing people who have contributed to this project! ๐
See our complete Contributors Hall of Fame for detailed recognition and contribution statistics.
This project is licensed under the MIT License - see the file for details.
โญ Found this action helpful? Give it a star and share it with your team!
๐ View Documentation โข โก Performance Reports โข ๐ Security Dashboard โข ๐ฌ Join Discussions