From b7a9db5c9b8d8838b5ca6e9592e2a1e80751b099 Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Wed, 7 Jul 2021 23:32:59 -0400 Subject: [PATCH 1/3] brand: GitHub --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5e3a565b..38043bc4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Paths Changes Filter -[Github Action](https://github.com/features/actions) that enables conditional execution of workflow steps and jobs, based on the files modified by pull request, on a feature +[GitHub Action](https://github.com/features/actions) that enables conditional execution of workflow steps and jobs, based on the files modified by pull request, on a feature branch, or by the recently pushed commits. Run slow tasks like integration tests or deployments only for changed components. It saves time and resources, especially in monorepo setups. -Github workflows built-in [path filters](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpaths) +GitHub workflows built-in [path filters](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpaths) don't allow this because they don't work on a level of individual jobs or steps. **Real world usage examples:** @@ -17,7 +17,7 @@ don't allow this because they don't work on a level of individual jobs or steps. - Workflow triggered by **[pull_request](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request)** or **[pull_request_target](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target)** event - Changes are detected against the pull request base branch - - Uses Github REST API to fetch a list of modified files + - Uses GitHub REST API to fetch a list of modified files - **Feature branches:** - Workflow triggered by **[push](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push)** or any other **[event](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)** @@ -139,9 +139,9 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob working-directory: '' # Personal access token used to fetch a list of changed files - # from Github REST API. + # 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. + # 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 }} From a0e43af4ae73d14ab574ee7bab8b582409d3cd2b Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Wed, 7 Jul 2021 23:33:53 -0400 Subject: [PATCH 2/3] Split yaml sections --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 38043bc4..41f39a42 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ don't allow this because they don't work on a level of individual jobs or steps. - 'src/**' # run only if some file in 'src' folder was changed - if: steps.changes.outputs.src == 'true' +- if: steps.changes.outputs.src == 'true' run: ... ``` For more scenarios see [examples](#examples) section. From 74cfa7995e20515d5686791046cd9b3d93f919fe Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Wed, 7 Jul 2021 23:52:11 -0400 Subject: [PATCH 3/3] Markdown fixes --- README.md | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 41f39a42..106b471a 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,12 @@ GitHub workflows built-in [path filters](https://docs.github.com/en/actions/refe don't allow this because they don't work on a level of individual jobs or steps. **Real world usage examples:** + - [sentry.io](https://sentry.io/) - [backend-test-py3.6.yml](https://github.com/getsentry/sentry/blob/ca0e43dc5602a9ab2e06d3f6397cc48fb5a78541/.github/workflows/backend-test-py3.6.yml#L32) - [GoogleChrome/web.dev](https://web.dev/) - [lint-and-test-workflow.yml](https://github.com/GoogleChrome/web.dev/blob/e1f0c28964e99ce6a996c1e3fd3ee1985a7a04f6/.github/workflows/lint-and-test-workflow.yml#L33) +## Supported workflows -## Supported workflows: - **Pull requests:** - Workflow triggered by **[pull_request](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request)** or **[pull_request_target](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target)** event @@ -41,6 +42,7 @@ don't allow this because they don't work on a level of individual jobs or steps. - Untracked files are ignored ## Example + ```yaml - uses: dorny/paths-filter@v2 id: changes @@ -53,9 +55,11 @@ don't allow this because they don't work on a level of individual jobs or steps. - if: steps.changes.outputs.src == 'true' run: ... ``` + For more scenarios see [examples](#examples) section. -## Notes: +## Notes + - Paths expressions are evaluated using [picomatch](https://github.com/micromatch/picomatch) library. Documentation for path expression format can be found on the project GitHub page. - Picomatch [dot](https://github.com/micromatch/picomatch#options) option is set to true. @@ -64,8 +68,8 @@ For more scenarios see [examples](#examples) section. - Local execution with [act](https://github.com/nektos/act) works only with alternative runner image. Default runner doesn't have `git` binary. - Use: `act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04` +## What's New -# What's New - Add `ref` input parameter - Add `list-files: csv` format - Configure matrix job to run for each folder with changes using `changes` output @@ -74,7 +78,7 @@ For more scenarios see [examples](#examples) section. For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob/master/CHANGELOG.md) -# Usage +## Usage ```yaml - uses: dorny/paths-filter@v2 @@ -149,16 +153,17 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob ``` ## Outputs + - 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 + - `'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 an output variable with the name `${FILTER_NAME}_count` to the count of matching files. - If enabled, for each filter it sets an output variable with the name `${FILTER_NAME}_files`. It will contain a list of all files matching the filter. - `changes` - JSON array with names of all filters matching any of the changed files. -# Examples +## Examples -## Conditional execution +### Conditional execution
Execute step in a workflow job only if some file in a subfolder is changed @@ -193,6 +198,7 @@ jobs: if: steps.filter.outputs.backend == 'true' || steps.filter.outputs.frontend == 'true' run: ... ``` +
@@ -236,6 +242,7 @@ jobs: - uses: actions/checkout@v2 - ... ``` +
@@ -271,9 +278,10 @@ jobs: - uses: actions/checkout@v2 - ... ``` +
-## Change detection workflows +### Change detection workflows
Pull requests: Detect changes against PR base branch @@ -294,6 +302,7 @@ jobs: with: filters: ... # Configure your filters ``` +
@@ -319,6 +328,7 @@ jobs: base: develop # Change detection against merge-base with this branch filters: ... # Configure your filters ``` +
@@ -346,6 +356,7 @@ jobs: base: ${{ github.ref }} filters: ... # Configure your filters ``` +
@@ -375,9 +386,10 @@ jobs: base: HEAD filters: ... # Configure your filters ``` +
-## Advanced options +### Advanced options
Define filter rules in own file @@ -389,6 +401,7 @@ jobs: # Path to file where filters are defined filters: .github/filters.yaml ``` +
@@ -409,6 +422,7 @@ jobs: - *shared - src/** ``` +
@@ -434,10 +448,10 @@ jobs: addedOrModifiedAnchors: - added|modified: *shared ``` -
+ -## Custom processing of changed files +### Custom processing of changed files
Passing list of modified files as command line args in Linux shell @@ -462,6 +476,7 @@ jobs: if: ${{ steps.filter.outputs.markdown == 'true' }} run: npx textlint ${{ steps.filter.outputs.markdown_files }} ``` +
@@ -486,11 +501,13 @@ jobs: with: files: ${{ steps.filter.outputs.changed_files }} ``` +
-# See also +## See also + - [test-reporter](https://github.com/dorny/test-reporter) - Displays test results from popular testing frameworks directly in GitHub -# License +## License The scripts and documentation in this project are released under the [MIT License](https://github.com/dorny/paths-filter/blob/master/LICENSE)