From c2766acabb30331051459cc8edfc17058eff8c13 Mon Sep 17 00:00:00 2001 From: Michal Dorner Date: Fri, 29 Jan 2021 19:54:44 +0100 Subject: [PATCH 1/2] Add `${FILTER_NAME}_count` output --- README.md | 1 + dist/index.js | 1 + src/main.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/README.md b/README.md index b632837..e623477 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,7 @@ For more information see [CHANGELOG](https://github.com/dorny/paths-filter/blob/ - For each filter it sets output variable named by the filter to the text: - `'true'` - if **any** of changed files matches any of filter rules - `'false'` - if **none** of changed files matches any of filter rules +- For each filter it sets output variable with name `${FILTER_NAME}_count` to the count of matching files. - If enabled, for each filter it sets output variable with name `${FILTER_NAME}_files`. It will contain list of all files matching the filter. - `changes` - JSON array with names of all filters matching any of changed files. diff --git a/dist/index.js b/dist/index.js index d2b9ab4..35a3f9e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4806,6 +4806,7 @@ function exportResults(results, format) { core.info('Matching files: none'); } core.setOutput(key, value); + core.setOutput(`${key}_count`, files.length); if (format !== 'none') { const filesValue = serializeExport(files, format); core.setOutput(`${key}_files`, filesValue); diff --git a/src/main.ts b/src/main.ts index 844b5e4..3e9522f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -190,6 +190,7 @@ function exportResults(results: FilterResults, format: ExportFormat): void { } core.setOutput(key, value) + core.setOutput(`${key}_count`, files.length) if (format !== 'none') { const filesValue = serializeExport(files, format) core.setOutput(`${key}_files`, filesValue) From a2730492f04253a2f2133b1fb62a5ff8fabf2b5e Mon Sep 17 00:00:00 2001 From: Michal Dorner Date: Fri, 29 Jan 2021 19:59:09 +0100 Subject: [PATCH 2/2] Add test for `${FILTER_NAME}_count` output --- .github/workflows/pull-request-verification.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pull-request-verification.yml b/.github/workflows/pull-request-verification.yml index b18d7ba..801c7ce 100644 --- a/.github/workflows/pull-request-verification.yml +++ b/.github/workflows/pull-request-verification.yml @@ -90,6 +90,9 @@ jobs: - name: filter-test if: steps.filter.outputs.local != 'true' run: exit 1 + - name: count-test + if: steps.filter.outputs.local_count != 1 + run: exit 1 test-change-type: runs-on: ubuntu-latest