### Configure Filters with Inline YAML Source: https://context7.com/dorny/paths-filter/llms.txt Define named filter rules using an inline YAML string for the `filters` input. This example shows how to filter changes for 'backend', 'frontend', and 'docs' components. ```yaml - uses: dorny/paths-filter@v4 id: changes with: filters: | backend: - 'backend/**' - 'shared/**' frontend: - 'frontend/**' - 'shared/**' docs: - '**/*.md' - 'docs/**' ``` ```yaml - name: Run backend tests if: steps.changes.outputs.backend == 'true' run: npm run test:backend ``` ```yaml - name: Run frontend tests if: steps.changes.outputs.frontend == 'true' run: npm run test:frontend ``` ```yaml - name: Build docs if: steps.changes.outputs.docs == 'true' run: npm run build:docs ``` -------------------------------- ### Configure Paths Filter Action Source: https://github.com/dorny/paths-filter/blob/master/README.md Example of how to configure the paths-filter action in a GitHub Actions workflow. This snippet shows the basic structure and common parameters. ```yaml - uses: dorny/paths-filter@v4 with: # Defines filters applied to detected changed files. # Each filter has a name and a list of rules. # Rule is a glob expression - paths of all changed # files are matched against it. # Rule can optionally specify if the file # should be added, modified, or deleted. # For each filter, there will be a corresponding output variable to # indicate if there's a changed file matching any of the rules. # Optionally, there can be a second output variable # set to list of all files matching the filter. # Filters can be provided inline as a string (containing valid YAML document), # or as a relative path to a file (e.g.: .github/filters.yaml). # Filters syntax is documented by example - see examples section. filters: '' # Branch, tag, or commit SHA against which the changes will be detected. # If it references the same branch it was pushed to, # changes are detected against the most recent commit before the push. # If it is empty and action is triggered by merge_group event, # the base commit in the event will be used. # Otherwise, it uses git merge-base to find the best common ancestor between # current branch (HEAD) and base. # When merge-base is found, it's used for change detection - only changes # introduced by the current branch are considered. # All files are considered as added if there is no common ancestor with # base branch or no previous commit. # This option is ignored if action is triggered by pull_request event. # Default: repository default branch (e.g. master) base: '' # Git reference (e.g. branch name) from which the changes will be detected. # Useful when workflow can be triggered only on the default branch (e.g. repository_dispatch event) # but you want to get changes on a different branch. # If this is empty and action is triggered by merge_group event, # the head commit in the event will be used. # This option is ignored if action is triggered by pull_request event. # default: ${{ github.ref }} ref: # How many commits are initially fetched from the base branch. # If needed, each subsequent fetch doubles the # previously requested number of commits until the merge-base # is found, or there are no more commits in the history. # This option takes effect only when changes are detected # using git against base branch (feature branch workflow). # Default: 100 initial-fetch-depth: '' # Enables listing of files matching the filter: # 'none' - Disables listing of matching files (default). # 'csv' - Coma separated list of filenames. # If needed, it uses double quotes to wrap filename with unsafe characters. # 'json' - File paths are formatted as JSON array. # 'shell' - Space delimited list usable as command-line argument list in Linux shell. # If needed, it uses single or double quotes to wrap filename with unsafe characters. # 'escape'- Space delimited list usable as command-line argument list in Linux shell. # Backslash escapes every potentially unsafe character. # Default: none list-files: '' # Relative path under $GITHUB_WORKSPACE where the repository was checked out. working-directory: '' # Personal access token used to fetch a list of changed files # from GitHub REST API. # It's only used if action is triggered by a pull request event. # GitHub token from workflow context is used as default value. # If an empty string is provided, the action falls back to detect # changes using git commands. # Default: ${{ github.token }} token: '' # Optional parameter to override the default behavior of file matching algorithm. # By default files that match at least one pattern defined by the filters will be included. # This parameter allows to override the "at least one pattern" behavior to make it so that # all of the patterns have to match or otherwise the file is excluded. # An example scenario where this is useful if you would like to match all # .ts files in a sub-directory but not .md files. # The filters below will match markdown files despite the exclusion syntax UNLESS # you specify 'every' as the predicate-quantifier parameter. When you do that, # it will only match the .ts files in the subdirectory as expected. # # backend: # - 'pkg/a/b/c/**' # - '!**/*.jpeg' # - '!**/*.md' predicate-quantifier: 'some' ``` -------------------------------- ### Configure `list-files` Output (CSV) Source: https://context7.com/dorny/paths-filter/llms.txt Enable the `list-files` input with the `csv` option to get a comma-separated list of matched file paths for each filter. This output is useful for subsequent steps that need to process specific changed files. ```yaml - uses: dorny/paths-filter@v4 id: changes with: filters: | backend: - 'backend/**' list-files: csv ``` -------------------------------- ### JSON Format - Pass Matched Files to Custom Action Source: https://context7.com/dorny/paths-filter/llms.txt Use 'json' format to pass matched file paths as a JSON array to a custom action. This example processes all changed files. ```yaml - uses: dorny/paths-filter@v4 id: filter with: list-files: json filters: | changed: - '**' ``` -------------------------------- ### Conditional Job Execution Based on File Changes Source: https://github.com/dorny/paths-filter/blob/master/README.md This example demonstrates how to trigger entire jobs based on file modifications. A 'changes' job performs the path filtering, and its outputs are used to conditionally run subsequent 'backend' and 'frontend' jobs. ```yaml jobs: # JOB to run change detection changes: runs-on: ubuntu-latest # Required permissions permissions: pull-requests: read # Set job outputs to values from filter step outputs: backend: ${{ steps.filter.outputs.backend }} frontend: ${{ steps.filter.outputs.frontend }} steps: # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@v4 id: filter with: filters: | backend: - 'backend/**' frontend: - 'frontend/**' # JOB to build and test backend code backend: needs: changes if: ${{ needs.changes.outputs.backend == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - ... # JOB to build and test frontend code frontend: needs: changes if: ${{ needs.changes.outputs.frontend == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - ... ``` -------------------------------- ### Configure `list-files` Output (Shell) Source: https://context7.com/dorny/paths-filter/llms.txt Use `list-files: shell` to get a space-delimited list of matched file paths, with unsafe filenames wrapped in single or double quotes. This is suitable for direct use in shell commands. ```yaml - uses: dorny/paths-filter@v4 id: changes with: filters: | backend: - 'backend/**' list-files: shell ``` -------------------------------- ### Set Base for Change Detection (Feature Branch) Source: https://context7.com/dorny/paths-filter/llms.txt Configure the `base` input to compare changes against a specific branch, like 'develop', for feature branches. This example demonstrates filtering for 'api' changes. ```yaml on: push: branches: - 'feature/**' jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 20 # Helps find merge-base faster - uses: dorny/paths-filter@v4 id: filter with: base: develop filters: | api: - 'src/api/**' - name: Run API tests if: steps.filter.outputs.api == 'true' run: npm run test:api ``` -------------------------------- ### Define Filters and Access Outputs in GitHub Actions Source: https://context7.com/dorny/paths-filter/llms.txt Configure filters for backend and frontend directories and access the 'changes' output to drive matrix jobs. This setup is useful for triggering specific jobs based on which parts of the codebase have changed. ```yaml jobs: detect-changes: runs-on: ubuntu-latest permissions: pull-requests: read outputs: packages: ${{ steps.filter.outputs.changes }} backend: ${{ steps.filter.outputs.backend }} frontend: ${{ steps.filter.outputs.frontend }} steps: - uses: dorny/paths-filter@v4 id: filter with: filters: | backend: src/backend frontend: src/frontend package1: packages/package1 package2: packages/package2 # Conditional single job backend-ci: needs: detect-changes if: needs.detect-changes.outputs.backend == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: make test-backend # Matrix job — runs once per changed package package-ci: needs: detect-changes if: needs.detect-changes.outputs.packages != '[]' strategy: matrix: package: ${{ fromJSON(needs.detect-changes.outputs.packages) }} # If package1 and package2 both changed → matrix runs for each runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm test --workspace=packages/${{ matrix.package }} ``` -------------------------------- ### Shell Format - Pass Matched Files to Linter Source: https://context7.com/dorny/paths-filter/llms.txt Use 'shell' format to pass matched file paths directly to a linter. This example filters for Markdown and TypeScript files. ```yaml - uses: dorny/paths-filter@v4 id: filter with: list-files: shell filters: | markdown: - added|modified: '**/*.md' typescript: - added|modified: 'src/**/*.ts' ``` -------------------------------- ### Specify Ref for Change Detection Source: https://context7.com/dorny/paths-filter/llms.txt Use the `ref` input to specify the 'head' side of the comparison when the workflow triggers on a different event or branch than the one being inspected. This example inspects changes on a feature branch for 'services' deployment. ```yaml on: repository_dispatch jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.client_payload.branch }} - uses: dorny/paths-filter@v4 id: filter with: ref: ${{ github.event.client_payload.branch }} base: main filters: | services: - 'services/**' - name: Deploy services if: steps.filter.outputs.services == 'true' run: ./scripts/deploy.sh ``` -------------------------------- ### Set Base for Change Detection (Long-Lived Branch) Source: https://context7.com/dorny/paths-filter/llms.txt When triggered on a long-lived branch, set `base` to `${{ github.ref }}` to compare against the previous commit on the same branch. This example filters for 'infra' changes. ```yaml on: push: branches: [master, develop, 'release/**'] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v4 id: filter with: base: ${{ github.ref }} filters: | infra: - 'terraform/**' - name: Apply Terraform if: steps.filter.outputs.infra == 'true' run: terraform apply -auto-approve ``` -------------------------------- ### Configure Filters Using an External YAML File Source: https://context7.com/dorny/paths-filter/llms.txt Store filter definitions in a separate `.github/filters.yaml` file for better organization and reusability. The action automatically detects the path to this file. ```yaml # .github/filters.yaml backend: - 'backend/**' - 'shared/**' frontend: - 'frontend/**' - 'shared/**' infra: - 'terraform/**' - '.github/workflows/**' ``` ```yaml # .github/workflows/ci.yml - uses: dorny/paths-filter@v4 id: filter with: filters: .github/filters.yaml # path detected automatically (no newline/colon) - if: steps.filter.outputs.infra == 'true' run: terraform plan ``` -------------------------------- ### Configure `list-files` Output (JSON) Source: https://context7.com/dorny/paths-filter/llms.txt Set `list-files` to `json` to obtain a JSON array of matched file paths for each filter. This format is easily parsable in subsequent steps, especially for matrix strategies. ```yaml - uses: dorny/paths-filter@v4 id: changes with: filters: | backend: - 'backend/**' list-files: json ``` -------------------------------- ### Advanced Filter Syntax with Glob Patterns and Change Statuses Source: https://context7.com/dorny/paths-filter/llms.txt Demonstrates various filter configurations including simple strings, lists of patterns with negation, and change-status qualified patterns (added, modified, deleted). Utilizes YAML anchors for pattern reuse. ```yaml # All filter syntax variants in one place - uses: dorny/paths-filter@v4 id: filter with: filters: | # 1. Simple inline string docs: 'docs/**' # 2. List of patterns (OR logic by default — any match triggers filter) backend: - 'src/backend/**' - 'config/backend.yaml' - '!src/backend/**/*.test.ts' # negation: exclude test files # 3. Change-status qualified patterns added-files: - added: '**' modified-ts: - modified: 'src/**/*.ts' added-or-modified: - added|modified: 'src/**' all-change-types: - added|deleted|modified: '**' # 4. YAML anchors for reuse shared: &shared - common/** - config/** frontend: - *shared # reuse shared patterns - frontend/** # 5. Anchors with change-status modified-shared: - modified: *shared # Accessing all output types - run: | echo "backend changed: ${{ steps.filter.outputs.backend }}" echo "backend file count: ${{ steps.filter.outputs.backend_count }}" echo "all changed filters: ${{ steps.filter.outputs.changes }}" # e.g.: # backend changed: true # backend file count: 3 # all changed filters: ["backend","frontend"] ``` -------------------------------- ### Configuring Matrix Jobs with Change Detection Source: https://github.com/dorny/paths-filter/blob/master/README.md This snippet shows how to use the paths-filter action to dynamically configure a matrix job. The 'changes' job outputs a JSON array of matching filters, which is then parsed to define the 'package' matrix for the 'build' job. ```yaml jobs: # JOB to run change detection changes: runs-on: ubuntu-latest # Required permissions permissions: pull-requests: read outputs: # Expose matched filters as job 'packages' output variable packages: ${{ steps.filter.outputs.changes }} steps: # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@v4 id: filter with: filters: | package1: src/package1 package2: src/package2 # JOB to build and test each of modified packages build: needs: changes strategy: matrix: # Parse JSON array containing names of all filters matching any of changed files # e.g. ['package1', 'package2'] if both package folders contains changes package: ${{ fromJSON(needs.changes.outputs.packages) }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - ... ``` -------------------------------- ### Configure `list-files` Output (Escape) Source: https://context7.com/dorny/paths-filter/llms.txt Set `list-files` to `escape` for a space-delimited list where every unsafe character in filenames is backslash-escaped. This provides maximum safety for shell interpretation. ```yaml - uses: dorny/paths-filter@v4 id: changes with: filters: | backend: - 'backend/**' list-files: escape ``` -------------------------------- ### Run Backend CI with 'every' Quantifier Source: https://context7.com/dorny/paths-filter/llms.txt Conditionally runs backend CI if the 'backend' filter, configured with 'every' quantifier for precise matching, is triggered. ```yaml - name: Run backend CI if: steps.filter.outputs.backend == 'true' run: make test-backend ``` -------------------------------- ### Use YAML Anchors for Reusable Path Expressions Source: https://github.com/dorny/paths-filter/blob/master/README.md Leverage YAML anchors and references to reuse path expressions within filter rules, promoting DRY principles. ```yaml - uses: dorny/paths-filter@v4 id: filter with: # &shared is YAML anchor, # *shared references previously defined anchor # src filter will match any path under common, config and src folders filters: | shared: &shared - common/** - config/** src: - *shared - src/** ``` -------------------------------- ### Detect Local/Uncommitted Changes with `base: HEAD` Source: https://context7.com/dorny/paths-filter/llms.txt Use the `base: HEAD` configuration to compare the working tree against the HEAD commit, useful for detecting files modified by a previous step like an auto-formatter. The `list-files: shell` option is used here. ```yaml # Detect files modified by a previous step (e.g., auto-formatter) - uses: actions/checkout@v4 - uses: my-org/auto-format@v1 # modifies files in place - uses: dorny/paths-filter@v4 id: filter with: base: HEAD # compares working tree against HEAD commit list-files: shell filters: | formatted: - '**' - name: Commit auto-formatted files if: steps.filter.outputs.formatted == 'true' run: | git add ${{ steps.filter.outputs.formatted_files }} git commit -m "chore: auto-format" git push ``` -------------------------------- ### Specify Working Directory for Checkout Path Source: https://context7.com/dorny/paths-filter/llms.txt Configures the action to operate within a specific subdirectory of the workspace. This is useful when `actions/checkout` uses a custom `path`. ```yaml - uses: actions/checkout@v4 with: path: my-repo - uses: dorny/paths-filter@v4 id: filter with: working-directory: my-repo filters: | src: - 'src/**' ``` -------------------------------- ### Pass Modified Files as Linux Shell Arguments Source: https://github.com/dorny/paths-filter/blob/master/README.md Enable listing of files matching filters and format them as space-delimited, shell-escaped arguments for Linux commands. ```yaml - uses: dorny/paths-filter@v4 id: filter with: # Enable listing of files matching each filter. # Paths to files will be available in `${FILTER_NAME}_files` output variable. # Paths will be escaped and space-delimited. # Output is usable as command-line argument list in Linux shell list-files: shell # In this example changed files will be checked by linter. # It doesn't make sense to lint deleted files. # Therefore we specify we are only interested in added or modified files. filters: | markdown: - added|modified: '*.md' - name: Lint Markdown if: ${{ steps.filter.outputs.markdown == 'true' }} run: npx textlint ${{ steps.filter.outputs.markdown_files }} ``` -------------------------------- ### Detect Local Changes (Staged/Unstaged) Source: https://github.com/dorny/paths-filter/blob/master/README.md Use this workflow to detect staged and unstaged local changes. It sets the base to 'HEAD' and triggers on push events to specified branches. ```yaml on: push: branches: # Push to following branches will trigger the workflow - master - develop - release/** jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 # Some action that modifies files tracked by git (e.g. code linter) - uses: johndoe/some-action@v1 # Filter to detect which files were modified # Changes could be, for example, automatically committed - uses: dorny/paths-filter@v4 id: filter with: base: HEAD filters: ... # Configure your filters ``` -------------------------------- ### Configure Filter for Pull Request Events Source: https://context7.com/dorny/paths-filter/llms.txt Set up the paths-filter action to detect changes relevant to a pull request targeting specific branches. The `token` defaults to `github.token`, and `base`/`ref` inputs are ignored for `pull_request` events. ```yaml on: pull_request: branches: [main, develop] merge_group: branches: [main] jobs: ci: runs-on: ubuntu-latest permissions: pull-requests: read # Required for API-based file listing steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v4 id: filter with: # token defaults to github.token — uses REST API to list changed files # base and ref inputs are ignored for pull_request events filters: | backend: - 'backend/**' - if: steps.filter.outputs.backend == 'true' run: make test-backend ``` -------------------------------- ### Set Initial Fetch Depth for Base Branch Comparison Source: https://context7.com/dorny/paths-filter/llms.txt Specifies the initial number of commits to fetch from the base branch when determining changed files. Defaults to 100. ```yaml - uses: dorny/paths-filter@v4 id: filter with: base: main initial-fetch-depth: '20' # start with 20 commits; doubles to 40, 80, ... filters: | src: - 'src/**' ``` -------------------------------- ### Detect Folder Changes with File Extension Filtering Source: https://github.com/dorny/paths-filter/blob/master/README.md Filter changes within a folder to only consider specific file extensions, useful for optimizing build and test processes. ```yaml - uses: dorny/paths-filter@v4 id: filter with: # This makes it so that all the patterns have to match a file for it to be # considered changed. Because we have the exclusions for .jpeg and .md files # the end result is that if those files are changed they will be ignored # because they don't match the respective rules excluding them. # # This can be leveraged to ensure that you only build & test software changes # that have real impact on the behavior of the code, e.g. you can set up your # build to run when Typescript/Rust/etc. files are changed but markdown # changes in the diff will be ignored and you consume less resources to build. predicate-quantifier: 'every' filters: | backend: - 'pkg/a/b/c/**' - '!**/*.jpeg' - '!**/*.md' ``` -------------------------------- ### Define Filter Rules in Own File Source: https://github.com/dorny/paths-filter/blob/master/README.md Specify a separate YAML file for defining filter rules to organize complex configurations. ```yaml - uses: dorny/paths-filter@v4 id: filter with: # Path to file where filters are defined filters: .github/filters.yaml ``` -------------------------------- ### Process Changed Files with JSON Output Source: https://context7.com/dorny/paths-filter/llms.txt A custom action that processes changed files, receiving the file list as a JSON array from the paths-filter action. ```yaml - name: Process changed files uses: my-org/file-processor@v1 with: files: ${{ steps.filter.outputs.changed_files }} # e.g. files = '["src/index.ts","src/utils.ts","README.md"]' ``` -------------------------------- ### Use GitHub Token for API-Based File Fetching Source: https://context7.com/dorny/paths-filter/llms.txt Explicitly sets the GitHub token for fetching changed files via the REST API. This is the default behavior and equivalent to `${{ github.token }}`. ```yaml - uses: dorny/paths-filter@v4 id: filter with: token: ${{ secrets.GITHUB_TOKEN }} # explicit (same as default) filters: | backend: - 'backend/**' ``` -------------------------------- ### Conditional Step Execution Based on File Changes Source: https://github.com/dorny/paths-filter/blob/master/README.md Use this snippet to run specific steps within a job only when files in designated subfolders have changed. It configures filters for 'backend' and 'frontend' directories and uses the output variables to conditionally execute subsequent steps. ```yaml jobs: tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: dorny/paths-filter@v4 id: filter with: filters: | backend: - 'backend/**' frontend: - 'frontend/**' # run only if 'backend' files were changed - name: backend tests if: steps.filter.outputs.backend == 'true' run: ... # run only if 'frontend' files were changed - name: frontend tests if: steps.filter.outputs.frontend == 'true' run: ... # run if 'backend' or 'frontend' files were changed - name: e2e tests if: steps.filter.outputs.backend == 'true' || steps.filter.outputs.frontend == 'true' run: ... ``` -------------------------------- ### Pass Modified Files as JSON Array to Another Action Source: https://github.com/dorny/paths-filter/blob/master/README.md Enable listing of files matching filters and format them as a JSON array, suitable for passing to other GitHub Actions. ```yaml - uses: dorny/paths-filter@v4 id: filter with: # Enable listing of files matching each filter. # Paths to files will be available in `${FILTER_NAME}_files` output variable. # Paths will be formatted as JSON array list-files: json # In this example all changed files are passed to the following action to do # some custom processing. filters: | changed: - '**' - name: Lint Markdown uses: johndoe/some-action@v1 with: files: ${{ steps.filter.outputs.changed_files }} ``` -------------------------------- ### Predicate Quantifier - 'every' for Exclusion Patterns Source: https://context7.com/dorny/paths-filter/llms.txt Configures the filter to require files to match ALL patterns within a filter group ('every') instead of any ('some'). This is useful for implementing exclusion patterns. ```yaml # 'some' (default): file matches if ANY pattern matches # 'every': file matches only if ALL patterns match — useful for exclusions - uses: dorny/paths-filter@v4 id: filter with: predicate-quantifier: 'every' filters: | backend: - 'pkg/backend/**' # must be under pkg/backend/ - '!**/*.md' # must NOT be a markdown file - '!**/*.jpeg' # must NOT be an image ``` -------------------------------- ### Consider File Change Types (Added, Modified, Deleted) Source: https://github.com/dorny/paths-filter/blob/master/README.md Filter rules based on the type of file change, such as 'added', 'modified', or 'deleted'. Supports combining types with '|'. ```yaml - uses: dorny/paths-filter@v4 id: filter with: # Changed file can be 'added', 'modified', or 'deleted'. # By default, the type of change is not considered. # Optionally, it's possible to specify it using nested # dictionary, where the type of change composes the key. # Multiple change types can be specified using `|` as the delimiter. filters: | shared: &shared - common/** - config/** addedOrModified: - added|modified: '**' allChanges: - added|deleted|modified: '**' addedOrModifiedAnchors: - added|modified: *shared ``` -------------------------------- ### Detect Feature Branch Changes Against Base Source: https://github.com/dorny/paths-filter/blob/master/README.md Configure this workflow to detect changes in a feature branch against a specified base branch (e.g., 'develop'). Triggers on push events to branches matching 'feature/**'. ```yaml on: push: branches: # Push to following branches will trigger the workflow - feature/** jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 with: # This may save additional git fetch roundtrip if # merge-base is found within latest 20 commits fetch-depth: 20 - uses: dorny/paths-filter@v4 id: filter with: base: develop # Change detection against merge-base with this branch filters: ... # Configure your filters ``` -------------------------------- ### Force Git-Based Diff by Emptying Token Source: https://context7.com/dorny/paths-filter/llms.txt Forces the action to use git-based diffing instead of the GitHub API by setting the token to an empty string. This bypasses API calls even for pull request events. ```yaml # Or force git-based detection (no API call) - uses: dorny/paths-filter@v4 id: filter with: token: '' filters: | backend: - 'backend/**' ``` -------------------------------- ### Lint Changed Markdown Files Source: https://context7.com/dorny/paths-filter/llms.txt Conditionally runs a linter on changed Markdown files if the 'markdown' filter in the paths-filter action matched. ```yaml - name: Lint changed Markdown files if: steps.filter.outputs.markdown == 'true' run: npx markdownlint ${{ steps.filter.outputs.markdown_files }} # e.g. expands to: npx markdownlint docs/guide.md 'docs/file with spaces.md' ``` -------------------------------- ### Filter Files in GitHub Actions Workflow Source: https://github.com/dorny/paths-filter/blob/master/README.md Use this snippet to define filters for file paths within a GitHub Actions workflow. The 'filters' input allows you to specify patterns for files that, when changed, will trigger subsequent steps. The output of this step can be checked using `steps..outputs.`. ```yaml - uses: dorny/paths-filter@v4 id: changes with: filters: | src: - 'src/**' # run only if some file in 'src' folder was changed - if: steps.changes.outputs.src == 'true' run: ... ``` -------------------------------- ### Type-check Changed TypeScript Files Source: https://context7.com/dorny/paths-filter/llms.txt Conditionally runs the TypeScript compiler for type checking on changed TypeScript files if the 'typescript' filter matched. ```yaml - name: Type-check changed TypeScript files if: steps.filter.outputs.typescript == 'true' run: npx tsc --noEmit ${{ steps.filter.outputs.typescript_files }} ``` -------------------------------- ### Detect PR Changes Against Base Branch Source: https://github.com/dorny/paths-filter/blob/master/README.md Use this workflow to detect changes in pull requests against the PR's base branch. Triggers on pull_request or merge_group events. ```yaml on: pull_request: branches: # PRs to the following branches will trigger the workflow - master - develop # Optionally you can use the action in the merge queue # if your repository enables the feature. merge_group: branches: - master - develop jobs: build: runs-on: ubuntu-latest # Required permissions permissions: pull-requests: read steps: - uses: actions/checkout@v6 - uses: dorny/paths-filter@v4 id: filter with: filters: ... # Configure your filters ``` -------------------------------- ### Detect Long-Lived Branch Changes Source: https://github.com/dorny/paths-filter/blob/master/README.md This workflow detects changes against the most recent commit on the same branch before a push event. It's suitable for long-lived branches like 'master', 'develop', or 'release/**'. ```yaml on: push: branches: # Push to the following branches will trigger the workflow - master - develop - release/** jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: dorny/paths-filter@v4 id: filter with: # Use context to get the branch where commits were pushed. # If there is only one long-lived branch (e.g. master), # you can specify it directly. # If it's not configured, the repository default branch is used. base: ${{ github.ref }} filters: ... # Configure your filters ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.