conditional-paths-action API Documentation - v1.0.0
    Preparing search index...

    conditional-paths-action API Documentation - v1.0.0

    Conditional Paths Action

    GitHub release GitHub Marketplace

    CI Pipeline CodeQL Security License Compliance Coverage

    Node.js 22 Node.js 24 Compatibility Matrix

    TypeScript ESM License: MIT

    Documentation Performance SBOM Discussions

    DevSecOps Supply Chain Pre-commit

    Note

    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?

    • Save Time & Resources: Run slow tasks like integration tests or deployments only for changed components
    • Perfect for Monorepos: Ideal for multi-package repositories where you only want to build/test affected packages
    • Flexible Detection: Works with pull requests, feature branches, and long-lived branches
    • Rich Output Formats: Get file lists in JSON, CSV, shell, or escaped formats
    • Advanced Filtering: Support for glob patterns, change types (added/modified/deleted), and predicate quantifiers
    Note

    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:

    • Node.js 22: Development, CI, and Dependabot compatibility
    • Node.js 24: GitHub Actions runtime validation
    • Matrix Strategy: fail-fast: false ensures both versions are fully tested
    strategy:
    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.

    ๐Ÿ”ฅ Quick Start - Minimal Usage
    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
    โš™๏ธ Advanced Usage with Matrix and Permissions
    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
    ๐Ÿงช Local Testing with act
    # 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:

    • Complete filter syntax and pattern matching
    • Advanced configuration options and use cases
    • Performance optimization tips and benchmarks
    • Security best practices and compliance
    • Local testing with act and troubleshooting guides

    Performance metrics and benchmarks are continuously monitored and available at /performance:

    • Bundle Size: 672KB optimized for GitHub Actions runtime
    • Cold Start: ~117K operations/sec for rapid sequential operations
    • Filter Processing: 46K+ operations/sec for complex pattern matching
    • Memory Usage: <50MB peak for typical monorepo workloads
    • Large Scale: Handles 10K+ files efficiently in monorepo environments

    Performance is automatically tracked through:

    • Automated Benchmarks: Run on every commit and release
    • Bundle Analysis: Size tracking with historical trends
    • Memory Profiling: Peak usage monitoring across different scenarios
    • Real-world Testing: Matrix testing across Node.js 22/24 environments

    This repository maintains the highest security standards with comprehensive automated scanning and transparent reporting:

    • CodeQL Analysis - Automated SAST vulnerability detection
    • Secret Scanning - GitLeaks integration prevents credential leaks
    • Dependency Scanning - Trivy scanner monitors for known CVEs
    • License Compliance - Validates all dependencies against approved licenses
    • SBOM Generation - Complete software supply chain transparency
    • Container Security - SHA-pinned actions with minimal permissions

    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:

    • ๐Ÿ” Supply Chain Transparency - Know exactly what's running in your workflows
    • โš–๏ธ License Compliance - Verify all dependencies meet your organization's requirements
    • ๐Ÿ›ก๏ธ Security Auditing - Track and respond to vulnerabilities in dependencies
    • ๐Ÿ“‹ Regulatory Compliance - Meet emerging software supply chain requirements

    We use the industry-standard CycloneDX v1.4 format, compatible with:

    • SPDX tools and validators
    • Dependency-Track and other SBOM analysis platforms
    • Government and enterprise compliance frameworks
    • Open-source supply chain security tools

    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:

    • ๐Ÿ”„ Automated Workflow: Issues and PRs are automatically added and moved through columns
    • ๐Ÿ“Š Progress Tracking: Clear visibility into what's being worked on and what's coming next
    • ๐ŸŽฏ Roadmap Visibility: See planned features and improvements
    • ๐Ÿค Contributor Coordination: Understand where help is needed most

    The board automatically syncs with:

    • New issues โ†’ Added to "Todo" column
    • In-progress PRs โ†’ Moved to "In Progress" column
    • Merged PRs โ†’ Moved to "Done" column
    • Released features โ†’ Archived

    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
    • Node.js 22: Required for local development (managed by mise)
    • Compatibility Testing: All changes tested against Node.js 22/24 matrix
    • Code Quality: ESLint, Prettier, TypeScript strict mode
    • Security: Pre-commit hooks enforce security and license compliance
    • Documentation: TSDoc required for all public APIs

    Thanks to all the amazing people who have contributed to this project! ๐Ÿ™Œ

    Contributors

    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!

    GitHub stars Follow @santosr2

    ๐Ÿ“– View Documentation โ€ข โšก Performance Reports โ€ข ๐Ÿ”’ Security Dashboard โ€ข ๐Ÿ’ฌ Join Discussions