Compare commits

...

5 Commits

Author SHA1 Message Date
Scott Crooks
fcaeabfbd8
Merge 4c5aaae1a5 into d8f7b061b2 2026-03-13 15:27:22 -04:00
Michal Dorner
d8f7b061b2
Merge pull request #302 from dorny/issue-299
Update README for v4
2026-03-13 20:16:52 +01:00
Michal Dorner
addbc147a9
Update README for v4 2026-03-13 20:14:22 +01:00
Scott Crooks
4c5aaae1a5
Merge branch 'master' into feat-add-any-all 2025-11-27 10:27:10 +01:00
Scott Crooks
7b47280cac
feat: adding any and all boolean outputs
This adds two boolean outputs `any` and `all` so that someone can track whether (1) any filter has at least one changed file, or (2) all filters have at least one changed file

Closes #266

Signed-off-by: Scott Crooks <scott.crooks@gmail.com>
2025-04-11 22:06:19 +02:00
4 changed files with 40 additions and 24 deletions

View File

@ -46,7 +46,7 @@ don't allow this because they don't work on a level of individual jobs or steps.
## Example
```yaml
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: changes
with:
filters: |
@ -72,7 +72,7 @@ For more scenarios see [examples](#examples) section.
## What's New
- New major release `v3` after update to Node 20 [Breaking change]
- New major release `v4` after update to Node 24 [Breaking change]
- Add `ref` input parameter
- Add `list-files: csv` format
- Configure matrix job to run for each folder with changes using `changes` output
@ -84,7 +84,7 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob
## Usage
```yaml
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
with:
# Defines filters applied to detected changed files.
# Each filter has a name and a list of rules.
@ -192,8 +192,8 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
@ -237,7 +237,7 @@ jobs:
frontend: ${{ steps.filter.outputs.frontend }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
@ -252,7 +252,7 @@ jobs:
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- ...
# JOB to build and test frontend code
@ -261,7 +261,7 @@ jobs:
if: ${{ needs.changes.outputs.frontend == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- ...
```
@ -283,7 +283,7 @@ jobs:
packages: ${{ steps.filter.outputs.changes }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
@ -300,7 +300,7 @@ jobs:
package: ${{ fromJSON(needs.changes.outputs.packages) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- ...
```
@ -324,8 +324,8 @@ jobs:
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
id: filter
with:
filters: ... # Configure your filters
@ -345,12 +345,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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@v3
- uses: dorny/paths-filter@v4
id: filter
with:
base: develop # Change detection against merge-base with this branch
@ -373,8 +373,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
id: filter
with:
# Use context to get the branch where commits were pushed.
@ -401,14 +401,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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@v3
- uses: dorny/paths-filter@v4
id: filter
with:
base: HEAD
@ -423,7 +423,7 @@ jobs:
<summary>Define filter rules in own file</summary>
```yaml
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: filter
with:
# Path to file where filters are defined
@ -436,7 +436,7 @@ jobs:
<summary>Use YAML anchors to reuse path expression(s) inside another rule</summary>
```yaml
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: filter
with:
# &shared is YAML anchor,
@ -457,7 +457,7 @@ jobs:
<summary>Consider if file was added, modified or deleted</summary>
```yaml
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: filter
with:
# Changed file can be 'added', 'modified', or 'deleted'.
@ -483,7 +483,7 @@ jobs:
<summary>Detect changes in folder only for some file extensions</summary>
```yaml
- uses: dorny/paths-filter@v3
- 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
@ -511,7 +511,7 @@ jobs:
<summary>Passing list of modified files as command line args in Linux shell</summary>
```yaml
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: filter
with:
# Enable listing of files matching each filter.
@ -537,7 +537,7 @@ jobs:
<summary>Passing list of modified files as JSON array to another action</summary>
```yaml
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: filter
with:
# Enable listing of files matching each filter.

View File

@ -50,6 +50,10 @@ inputs:
required: false
default: 'some'
outputs:
all_changed:
description: Boolean value indicating if all of the filters contained at least one changed file
any_changed:
description: Boolean value indicating if any of the filters contained at least one changed file
changes:
description: JSON array with names of all filters matching any of changed files
runs:

6
dist/index.js vendored
View File

@ -745,11 +745,14 @@ async function getChangedFilesFromApi(token, pullRequest) {
function exportResults(results, format) {
core.info('Results:');
const changes = [];
let anyChanged = false;
let allChanged = true;
for (const [key, files] of Object.entries(results)) {
const value = files.length > 0;
core.startGroup(`Filter ${key} = ${value}`);
if (files.length > 0) {
changes.push(key);
anyChanged = true;
core.info('Matching files:');
for (const file of files) {
core.info(`${file.filename} [${file.status}]`);
@ -757,6 +760,7 @@ function exportResults(results, format) {
}
else {
core.info('Matching files: none');
allChanged = false;
}
core.setOutput(key, value);
core.setOutput(`${key}_count`, files.length);
@ -764,6 +768,8 @@ function exportResults(results, format) {
const filesValue = serializeExport(files, format);
core.setOutput(`${key}_files`, filesValue);
}
core.setOutput('all_changed', allChanged);
core.setOutput('any_changed', anyChanged);
core.endGroup();
}
if (results['changes'] === undefined) {

View File

@ -231,17 +231,21 @@ async function getChangedFilesFromApi(token: string, pullRequest: PullRequestEve
function exportResults(results: FilterResults, format: ExportFormat): void {
core.info('Results:')
const changes = []
let anyChanged = false
let allChanged = true
for (const [key, files] of Object.entries(results)) {
const value = files.length > 0
core.startGroup(`Filter ${key} = ${value}`)
if (files.length > 0) {
changes.push(key)
anyChanged = true
core.info('Matching files:')
for (const file of files) {
core.info(`${file.filename} [${file.status}]`)
}
} else {
core.info('Matching files: none')
allChanged = false
}
core.setOutput(key, value)
@ -250,6 +254,8 @@ function exportResults(results: FilterResults, format: ExportFormat): void {
const filesValue = serializeExport(files, format)
core.setOutput(`${key}_files`, filesValue)
}
core.setOutput('all_changed', allChanged)
core.setOutput('any_changed', anyChanged)
core.endGroup()
}