{"id":47175,"date":"2026-11-24T22:04:42","date_gmt":"2026-11-24T22:04:42","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=47175"},"modified":"2026-11-24T22:04:42","modified_gmt":"2026-11-24T22:04:42","slug":"github-actions-paths-filter-complete-guide","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/github-actions-paths-filter-complete-guide\/","title":{"rendered":"GitHub Actions: paths-filter complete Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><code>dorny\/paths-filter<\/code> is a GitHub Action that checks which files changed in a pull request or push. It sets a <code>true<\/code>\/<code>false<\/code> output for each named filter, so later steps or jobs run only when relevant code changed. This guide explains the examples above, fixes the bugs in them (including an exclusion pattern that never excludes anything), and adds complete workflows for v3 of the action.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example 1 &#8211; Using paths-filter in Seprate file<\/h2>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/c57883862ca2f9b6a8c6e43be6db311b.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Example 2<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">  setup-env:\n    runs-on: ${{ github.event.pull_request.user.login == <span class=\"hljs-string\">'dependabot&#91;bot]'<\/span> &amp;&amp; <span class=\"hljs-string\">'arc-runners-dependabot'<\/span> || <span class=\"hljs-string\">'arc-runners-platform'<\/span> }}\n    <span class=\"hljs-attr\">if<\/span>: ${{ !contains(github.event.pull_request.labels.*.name, <span class=\"hljs-string\">'gha-skip-preclean'<\/span>) }}\n    timeout-minutes: <span class=\"hljs-number\">20<\/span>\n    <span class=\"hljs-attr\">steps<\/span>:\n      - name: Clean environment\n        <span class=\"hljs-attr\">run<\/span>: |\n          kubectl <span class=\"hljs-keyword\">delete<\/span> ns ${{ env.NAMESPACE }} || <span class=\"hljs-literal\">true<\/span>\n\n      - name: Checkout Platform\n        <span class=\"hljs-attr\">uses<\/span>: actions\/checkout@v4\n        <span class=\"hljs-attr\">with<\/span>:\n          ref: ${{ github.event.pull_request.head.sha }}\n\t\n\t  - name: Enable build based on the changes\n\t    <span class=\"hljs-attr\">uses<\/span>: dorny\/paths-filter@v3\n        <span class=\"hljs-attr\">id<\/span>: filter\n        <span class=\"hljs-attr\">with<\/span>:\n          filters: |\n            build:\n              - <span class=\"hljs-string\">'cpp\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'docker\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'golang\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'jenkins\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'portal\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'supd2\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'tools\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'!tools\/dir1\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'!tools\/dir2\/**'<\/span>\n\t\t\t  - <span class=\"hljs-string\">'!**\/*.jpeg'<\/span>\n              - <span class=\"hljs-string\">'!**\/*.md'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 3<\/h2>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/7822a208fce23e3cb9a3c7a6e3d9af96.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Example 4<\/h2>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/8effeb82e138f6d4f643ce4d5f1de43b.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Example 5<\/h2>\n\n\n\nhttps:\/\/gist.github.com\/devops-school\/9f911252a34f632ad96f10a8454b557d\n\n\n\n<h2 class=\"wp-block-heading\">Reference<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/dorny\/paths-filter\" rel=\"noopener\">https:\/\/github.com\/dorny\/paths-filter<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Why use paths-filter instead of on.paths<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GitHub Actions already supports <code>on.push.paths<\/code> and <code>on.pull_request.paths<\/code>, but those filters decide whether the <strong>whole workflow<\/strong> runs. <code>paths-filter<\/code> runs inside the workflow, so one workflow can decide separately for each job or step. This matters in monorepos and wherever branch protection depends on required checks.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Need<\/th><th>on.paths<\/th><th>dorny\/paths-filter<\/th><\/tr><\/thead><tbody><tr><td>Skip the entire workflow when nothing relevant changed<\/td><td>Yes<\/td><td>Possible, but more work<\/td><\/tr><tr><td>Run different jobs or steps for different folders<\/td><td>No<\/td><td>Yes, one output per filter<\/td><\/tr><tr><td>Required status checks when the workflow is skipped<\/td><td>The check stays pending and blocks the merge<\/td><td>Jobs report as skipped and the check can still pass<\/td><\/tr><tr><td>React only to added, modified or deleted files<\/td><td>No<\/td><td>Yes, for example <code>added|modified: &#039;**\/*.py&#039;<\/code><\/td><\/tr><tr><td>Get the list of matching files for linters<\/td><td>No<\/td><td>Yes, with <code>list-files<\/code><\/td><\/tr><tr><td>Build a matrix from the changed packages<\/td><td>No<\/td><td>Yes, with the <code>changes<\/code> output<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Inputs and outputs you will actually use<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Input<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td><code>filters<\/code><\/td><td>Inline YAML, or the path to a YAML file in the repository (as in Example 1)<\/td><\/tr><tr><td><code>token<\/code><\/td><td>Defaults to <code>github.token<\/code>. On pull requests it is used to read the changed files from the GitHub API<\/td><\/tr><tr><td><code>base<\/code> \/ <code>ref<\/code><\/td><td>The git refs to compare. You need <code>base<\/code> for events such as <code>workflow_dispatch<\/code> or <code>schedule<\/code><\/td><\/tr><tr><td><code>list-files<\/code><\/td><td><code>none<\/code> (the default), <code>csv<\/code>, <code>json<\/code>, <code>shell<\/code> or <code>escape<\/code>. Adds a <code>&lt;filter&gt;_files<\/code> output<\/td><\/tr><tr><td><code>predicate-quantifier<\/code><\/td><td><code>some<\/code> (the default) or <code>every<\/code>. Controls how the patterns inside one filter are combined<\/td><\/tr><tr><td><code>working-directory<\/code><\/td><td>The directory where git commands run, for push events<\/td><\/tr><tr><td><code>initial-fetch-depth<\/code><\/td><td>How many commits to fetch at first when the action has to find the merge base<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Output<\/th><th>Value<\/th><\/tr><\/thead><tbody><tr><td><code>&lt;filter&gt;<\/code><\/td><td><code>&#039;true&#039;<\/code> or <code>&#039;false&#039;<\/code> as a <strong>string<\/strong><\/td><\/tr><tr><td><code>&lt;filter&gt;_count<\/code><\/td><td>Number of changed files that match the filter<\/td><\/tr><tr><td><code>&lt;filter&gt;_files<\/code><\/td><td>Matching files, in the <code>list-files<\/code> format (only when <code>list-files<\/code> is enabled)<\/td><\/tr><tr><td><code>changes<\/code><\/td><td>JSON array of the names of every filter that matched, for example <code>[&quot;backend&quot;]<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Outputs are strings. Always compare against <code>&#039;true&#039;<\/code>, as in <code>steps.filter.outputs.backend == &#039;true&#039;<\/code>. Do not rely on a bare <code>steps.filter.outputs.backend<\/code>: the string <code>&#039;false&#039;<\/code> is not empty, so the expression treats it as truthy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How the change list is built depends on the event. On <code>pull_request<\/code>, the action calls the GitHub API, so checkout is optional, but the job needs <code>pull-requests: read<\/code>. On <code>push<\/code>, it uses git, so you must run <code>actions\/checkout<\/code> first. On a feature branch it compares against the merge base with the default branch. On the default branch or another long-lived branch, it compares against the commit before the push.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A complete job-level workflow<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The gist examples are fragments, and <code>examle.yaml<\/code> mixes two snippets with broken indentation, so it does not parse. The workflow below is complete. One job detects changes and exposes them as job outputs. The other jobs read those outputs through <code>needs<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">name: ci\n\non:\n  push:\n    branches: &#91;main]\n  pull_request:\n    branches: &#91;main]\n\npermissions:\n  contents: read\n  pull-requests: read\n\njobs:\n  changes:\n    runs-on: ubuntu-latest\n    outputs:\n      backend: ${{ steps.filter.outputs.backend }}\n      frontend: ${{ steps.filter.outputs.frontend }}\n    steps:\n      - uses: actions\/checkout@v4   <span class=\"hljs-comment\"># required for push events<\/span>\n      - uses: dorny\/paths-filter@v3\n        id: filter\n        with:\n          filters: |\n            backend:\n              - <span class=\"hljs-string\">'backend\/**'<\/span>\n              - <span class=\"hljs-string\">'requirements*.txt'<\/span>\n            frontend:\n              - <span class=\"hljs-string\">'frontend\/**'<\/span>\n              - <span class=\"hljs-string\">'package*.json'<\/span>\n\n  backend:\n    needs: changes\n    <span class=\"hljs-keyword\">if<\/span>: needs.changes.outputs.backend == <span class=\"hljs-string\">'true'<\/span>\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\/checkout@v4\n      - run: <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"run backend build and tests here\"<\/span>\n\n  frontend:\n    needs: changes\n    <span class=\"hljs-keyword\">if<\/span>: needs.changes.outputs.frontend == <span class=\"hljs-string\">'true'<\/span>\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\/checkout@v4\n      - run: <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"run frontend build and tests here\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The <code>outputs:<\/code> mapping on the <code>changes<\/code> job is required. Step outputs are not visible to other jobs until you map them to job outputs. If you forget this, <code>needs.changes.outputs.backend<\/code> is an empty string and the dependent jobs never run. The <code>files-changed<\/code> job in Example 1 does this mapping correctly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Exclusions and predicate-quantifier: fixing Example 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Example 2 has two problems. First, the step and the pattern list are indented with <strong>tab characters<\/strong>. YAML does not allow tabs for indentation, so GitHub rejects the workflow file. Second, there is a logic bug. With the default <code>predicate-quantifier: &#039;some&#039;<\/code>, a file matches a filter if it matches <strong>any one<\/strong> pattern in the list. A negated pattern such as <code>&#039;!**\/*.md&#039;<\/code> matches every file that is not Markdown. A change to <code>README.md<\/code> still matches <code>&#039;!tools\/dir1\/**&#039;<\/code>, so <code>build<\/code> comes out <code>true<\/code> for almost every change, and the exclusions do nothing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To fix this, set <code>predicate-quantifier: &#039;every&#039;<\/code>, so a file must match <strong>all<\/strong> the patterns. Then put the included folders into one brace pattern, because a single file cannot be inside both <code>cpp\/<\/code> and <code>docker\/<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">  setup-env:\n    runs-on: ${{ github.event.pull_request.user.login == <span class=\"hljs-string\">'dependabot&#91;bot]'<\/span> &amp;&amp; <span class=\"hljs-string\">'arc-runners-dependabot'<\/span> || <span class=\"hljs-string\">'arc-runners-platform'<\/span> }}\n    <span class=\"hljs-attr\">if<\/span>: ${{ !contains(github.event.pull_request.labels.*.name, <span class=\"hljs-string\">'gha-skip-preclean'<\/span>) }}\n    timeout-minutes: <span class=\"hljs-number\">20<\/span>\n    <span class=\"hljs-attr\">outputs<\/span>:\n      build: ${{ steps.filter.outputs.build }}\n    <span class=\"hljs-attr\">steps<\/span>:\n      - name: Clean environment\n        <span class=\"hljs-attr\">run<\/span>: kubectl <span class=\"hljs-keyword\">delete<\/span> ns <span class=\"hljs-string\">\"${{ env.NAMESPACE }}\"<\/span> --ignore-not-found\n\n      - name: Checkout Platform\n        <span class=\"hljs-attr\">uses<\/span>: actions\/checkout@v4\n        <span class=\"hljs-attr\">with<\/span>:\n          ref: ${{ github.event.pull_request.head.sha }}\n\n      - name: Enable build based on the changes\n        <span class=\"hljs-attr\">uses<\/span>: dorny\/paths-filter@v3\n        <span class=\"hljs-attr\">id<\/span>: filter\n        <span class=\"hljs-attr\">with<\/span>:\n          predicate-quantifier: <span class=\"hljs-string\">'every'<\/span>\n          <span class=\"hljs-attr\">filters<\/span>: |\n            build:\n              - <span class=\"hljs-string\">'{cpp,docker,golang,jenkins,portal,supd2,tools}\/**'<\/span>\n              - <span class=\"hljs-string\">'!tools\/dir1\/**'<\/span>\n              - <span class=\"hljs-string\">'!tools\/dir2\/**'<\/span>\n              - <span class=\"hljs-string\">'!**\/*.jpeg'<\/span>\n              - <span class=\"hljs-string\">'!**\/*.md'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><code>predicate-quantifier<\/code> applies to <strong>every<\/strong> filter in that step. If other filters need <code>some<\/code> behaviour, put them in a separate <code>paths-filter<\/code> step.<\/li>\n\n\n<li><code>--ignore-not-found<\/code> replaces <code>|| true<\/code>. It still lets a real <code>kubectl<\/code> error, such as a bad kubeconfig, fail the step instead of hiding it.<\/li>\n\n\n<li>The <code>build<\/code> job output lets later jobs use <code>if: needs.setup-env.outputs.build == &#039;true&#039;<\/code>.<\/li>\n\n\n<li>The <code>runs-on<\/code> expression selects a runner label for Dependabot pull requests. Runner scale sets like these are explained in <a href=\"https:\/\/www.devopsschool.com\/blog\/what-is-github-actions-runner-controller\/\">What Is GitHub Actions Runner Controller?<\/a>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Filters in a separate file, anchors and change types<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Example 1 sets <code>filters: .github\/file-filters.yml<\/code>. The action then reads the filters from a file in the repository, so the repository must be checked out first. The file <code>file-filters.yml<\/code> uses standard YAML anchors (<code>&amp;backend_src<\/code>) and aliases (<code>*backend_src<\/code>) to build larger filters from smaller ones. The action flattens the nested lists, so <code>backend_all<\/code> contains every pattern from <code>backend_src<\/code> plus its own patterns.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also restrict a pattern to certain change types: <code>added<\/code>, <code>modified<\/code>, <code>deleted<\/code>, <code>renamed<\/code>, <code>copied<\/code> or <code>unchanged<\/code>. Combine them with <code>|<\/code>, for example <code>added|modified: &#039;**\/*.py&#039;<\/code>. This is how the Sentry <code>lint<\/code> job avoids linting files that were deleted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example 1 still pins <code>getsentry\/paths-filter<\/code>, which is a fork of v2, and <code>actions\/checkout<\/code> v2, and it runs on <code>ubuntu-20.04<\/code>. GitHub has retired that hosted runner image. Older action majors also run on Node.js runtimes that GitHub has deprecated. For a new workflow, use <code>dorny\/paths-filter@v3<\/code>, a current <code>actions\/checkout<\/code> major and <code>ubuntu-latest<\/code> or <code>ubuntu-24.04<\/code>. If your security policy requires it, pin each action to a full commit SHA, as Sentry does.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Passing changed files to linters safely<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>py_linter.yml<\/code> gist puts <code>${{ steps.filter.outputs.py_scripts_filter_files }}<\/code> directly into a <code>run<\/code> script. File names in a pull request are controlled by the person who opened it. Placing them directly into a script is a script-injection risk, and a very long list can exceed the shell&#039;s argument limit. A safer pattern is to request JSON, pass it through an environment variable and expand it with <code>jq<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">      - uses: dorny\/paths-filter@v3\n        id: filter\n        with:\n          <span class=\"hljs-keyword\">list<\/span>-files: json\n          filters: |\n            py:\n              - added|modified: <span class=\"hljs-string\">'**\/*.py'<\/span>\n\n      - name: Lint changed Python files\n        <span class=\"hljs-keyword\">if<\/span>: steps.filter.outputs.py == <span class=\"hljs-string\">'true'<\/span>\n        env:\n          PY_FILES: ${{ steps.filter.outputs.py_files }}\n        run: |\n          <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"Linting ${{ steps.filter.outputs.py_count }} file(s)\"<\/span>\n          <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"$PY_FILES\"<\/span> | jq -r <span class=\"hljs-string\">'.&#91;]'<\/span> | xargs -r -d <span class=\"hljs-string\">'\\n'<\/span> python -m black --check<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Also, <code>py_linter.yml<\/code> sets <code>on.paths: &quot;**.py&quot;<\/code> and also runs <code>paths-filter<\/code>. That combination is valid: the trigger skips runs that do not touch Python files, and the filter supplies the file list. Remember, though, that the <code>on.paths<\/code> trigger causes the pending required-check problem described in the first section.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dynamic matrix from the changes output<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Example 4 builds a matrix from the <code>changes<\/code> output. The idea is sound, but there are two problems. First, the pattern <code>src\/package1<\/code> matches only a file at exactly that path, not the files inside the folder, so you need <code>src\/package1\/**<\/code>. Second, when no filter matches, <code>changes<\/code> is <code>[]<\/code>, and a matrix with no values fails the workflow. Guard the job with an <code>if<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">jobs:\n  changes:\n    runs-on: ubuntu-latest\n    <span class=\"hljs-attr\">permissions<\/span>:\n      pull-requests: read\n    <span class=\"hljs-attr\">outputs<\/span>:\n      packages: ${{ steps.filter.outputs.changes }}\n    <span class=\"hljs-attr\">steps<\/span>:\n      - uses: dorny\/paths-filter@v3\n        <span class=\"hljs-attr\">id<\/span>: filter\n        <span class=\"hljs-attr\">with<\/span>:\n          filters: |\n            package1: <span class=\"hljs-string\">'src\/package1\/**'<\/span>\n            <span class=\"hljs-attr\">package2<\/span>: <span class=\"hljs-string\">'src\/package2\/**'<\/span>\n\n  <span class=\"hljs-attr\">build<\/span>:\n    needs: changes\n    <span class=\"hljs-attr\">if<\/span>: needs.changes.outputs.packages != <span class=\"hljs-string\">'&#91;]'<\/span>\n    runs-on: ubuntu-latest\n    <span class=\"hljs-attr\">strategy<\/span>:\n      fail-fast: <span class=\"hljs-literal\">false<\/span>\n      <span class=\"hljs-attr\">matrix<\/span>:\n        package: ${{ fromJSON(needs.changes.outputs.packages) }}\n    <span class=\"hljs-attr\">steps<\/span>:\n      - uses: actions\/checkout@v4\n      - run: make -C <span class=\"hljs-string\">\"src\/${{ matrix.package }}\"<\/span> build<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> This job has no checkout step before <code>paths-filter<\/code>, so it only works on <code>pull_request<\/code> events. If the workflow also runs on <code>push<\/code>, add <code>actions\/checkout<\/code> before the filter step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Required status checks with skipped jobs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When a job is skipped by its <code>if<\/code> condition, GitHub reports it as successful for branch protection. However, check names change with matrix values, and keeping a long list of required checks up to date is fragile. Example 1 solves this with one aggregator job, <code>backend-required-check<\/code>. Make that job the only required check:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">  ci-ok:\n    <span class=\"hljs-keyword\">if<\/span>: always()\n    needs: &#91;changes, backend, frontend]\n    runs-on: ubuntu-latest\n    steps:\n      - name: Fail <span class=\"hljs-keyword\">if<\/span> any dependency failed <span class=\"hljs-keyword\">or<\/span> was cancelled\n        <span class=\"hljs-keyword\">if<\/span>: contains(needs.*.result, <span class=\"hljs-string\">'failure'<\/span>) || contains(needs.*.result, <span class=\"hljs-string\">'cancelled'<\/span>)\n        run: <span class=\"hljs-keyword\">exit<\/span> <span class=\"hljs-number\">1<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Without <code>if: always()<\/code>, the aggregator job would itself be skipped whenever a job it depends on fails, which hides the failure. For more on configuring required checks, see <a href=\"https:\/\/www.devopsschool.com\/blog\/github-repository-settings-essentials-2-hour-tutorial\/\">GitHub Repository Settings Essentials<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symptom<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td>Workflow file is invalid, with a YAML error<\/td><td>Tabs or mixed indentation, as in Example 2<\/td><td>Indent with spaces only, and run <code>yamllint<\/code> locally<\/td><\/tr><tr><td>Filter is always <code>true<\/code><\/td><td>Negated patterns with the default <code>some<\/code> quantifier<\/td><td>Use <code>predicate-quantifier: &#039;every&#039;<\/code> and a brace pattern for the included folders<\/td><\/tr><tr><td>Filter is never <code>true<\/code><\/td><td>Pattern without <code>\/**<\/code>, or paths written relative to the wrong directory<\/td><td>Use <code>dir\/**<\/code>. Patterns are matched against paths from the repository root<\/td><\/tr><tr><td>Dependent job never runs<\/td><td>Step outputs not mapped to job <code>outputs:<\/code><\/td><td>Add an <code>outputs:<\/code> block to the detection job<\/td><\/tr><tr><td><code>Resource not accessible by integration<\/code><\/td><td>Token cannot read the pull request<\/td><td>Grant <code>pull-requests: read<\/code><\/td><\/tr><tr><td>Git errors on push events<\/td><td>No checkout before the filter<\/td><td>Add <code>actions\/checkout<\/code> before <code>paths-filter<\/code><\/td><\/tr><tr><td>Error saying <code>base<\/code> is required<\/td><td>Event with no base branch, such as <code>workflow_dispatch<\/code> or <code>schedule<\/code><\/td><td>Set <code>base:<\/code> explicitly, for example <code>base: main<\/code><\/td><\/tr><tr><td>Matrix error when nothing changed<\/td><td><code>fromJSON(&#039;[]&#039;)<\/code> gives an empty matrix<\/td><td>Add <code>if: needs.changes.outputs.packages != &#039;[]&#039;<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To debug a filter, open the step log. The action prints the list of changed files and the result of each filter. You can also print <code>steps.filter.outputs.&lt;name&gt;_count<\/code> in a later step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Does dorny\/paths-filter need actions\/checkout?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Not for <code>pull_request<\/code> events, as long as the filters are inline. In that case it reads the changed files from the GitHub API and needs <code>pull-requests: read<\/code>. For <code>push<\/code> events, or when <code>filters<\/code> points to a file in the repository, you must run <code>actions\/checkout<\/code> first.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I exclude files or folders in paths-filter?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Add negated patterns such as <code>&#039;!**\/*.md&#039;<\/code> and set <code>predicate-quantifier: &#039;every&#039;<\/code>, so a file must match all patterns. With the default <code>some<\/code>, a negated pattern matches almost every file, so the filter comes out true for nearly any change.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why is my paths-filter output always false in another job?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Step outputs are not shared across jobs automatically. Map them under the detection job&#039;s <code>outputs:<\/code> key, then read them with <code>needs.&lt;job&gt;.outputs.&lt;name&gt; == &#039;true&#039;<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between on.paths and paths-filter?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>on.paths<\/code> decides whether the whole workflow is triggered. <code>paths-filter<\/code> runs inside the workflow and can switch individual jobs or steps on or off. Because the workflow always runs, required status checks are still reported.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Which version of paths-filter should I use?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>dorny\/paths-filter@v3<\/code>. It runs on a current Node.js runtime and supports <code>predicate-quantifier<\/code>. Older v2 tags and forks run on Node.js versions that GitHub Actions has deprecated.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/github-actions-essentials-learn-ci-cd-in-2-hours\/\">GitHub Actions Essentials \u2014 Learn CI\/CD in 2 Hours<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/github-actions-ci-cd-automation-devops-engineering\/\">GitHub Actions \u2014 CI\/CD Automation &amp; DevOps Engineering<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/what-is-github-actions-runner-controller\/\">What Is GitHub Actions Runner Controller?<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/github-repository-settings-essentials-2-hour-tutorial\/\">GitHub Repository Settings Essentials \u2014 2-Hour Tutorial<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/devops\/github\/\">More GitHub tutorials<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>dorny\/paths-filter is a GitHub Action that checks which files changed in a pull request or push. It sets a true\/false output for each named filter, so later&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5204],"tags":[26194],"class_list":["post-47175","post","type-post","status-publish","format-standard","hentry","category-github","tag-github-actions"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=47175"}],"version-history":[{"count":7,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47175\/revisions"}],"predecessor-version":[{"id":80189,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47175\/revisions\/80189"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=47175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=47175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=47175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}