Skip to content

Commit 1ec7035

Browse files
authored
Merge pull request dorny#95 from jsoref/misc
Improve README
2 parents b2feaf1 + 74cfa79 commit 1ec7035

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

README.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
# Paths Changes Filter
22

3-
[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
3+
[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
44
branch, or by the recently pushed commits.
55

66
Run slow tasks like integration tests or deployments only for changed components. It saves time and resources, especially in monorepo setups.
7-
Github workflows built-in [path filters](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpaths)
7+
GitHub workflows built-in [path filters](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpaths)
88
don't allow this because they don't work on a level of individual jobs or steps.
99

1010
**Real world usage examples:**
11+
1112
- [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)
1213
- [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)
1314

15+
## Supported workflows
1416

15-
## Supported workflows:
1617
- **Pull requests:**
1718
- Workflow triggered by **[pull_request](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request)**
1819
or **[pull_request_target](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target)** event
1920
- Changes are detected against the pull request base branch
20-
- Uses Github REST API to fetch a list of modified files
21+
- Uses GitHub REST API to fetch a list of modified files
2122
- **Feature branches:**
2223
- Workflow triggered by **[push](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push)**
2324
or any other **[event](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)**
@@ -41,6 +42,7 @@ don't allow this because they don't work on a level of individual jobs or steps.
4142
- Untracked files are ignored
4243

4344
## Example
45+
4446
```yaml
4547
- uses: dorny/paths-filter@v2
4648
id: changes
@@ -50,12 +52,14 @@ don't allow this because they don't work on a level of individual jobs or steps.
5052
- 'src/**'
5153
5254
# run only if some file in 'src' folder was changed
53-
if: steps.changes.outputs.src == 'true'
55+
- if: steps.changes.outputs.src == 'true'
5456
run: ...
5557
```
58+
5659
For more scenarios see [examples](#examples) section.
5760
58-
## Notes:
61+
## Notes
62+
5963
- Paths expressions are evaluated using [picomatch](https://github.com/micromatch/picomatch) library.
6064
Documentation for path expression format can be found on the project GitHub page.
6165
- Picomatch [dot](https://github.com/micromatch/picomatch#options) option is set to true.
@@ -64,8 +68,8 @@ For more scenarios see [examples](#examples) section.
6468
- Local execution with [act](https://github.com/nektos/act) works only with alternative runner image. Default runner doesn't have `git` binary.
6569
- Use: `act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04`
6670

71+
## What's New
6772

68-
# What's New
6973
- Add `ref` input parameter
7074
- Add `list-files: csv` format
7175
- Configure matrix job to run for each folder with changes using `changes` output
@@ -74,7 +78,7 @@ For more scenarios see [examples](#examples) section.
7478

7579
For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob/master/CHANGELOG.md)
7680

77-
# Usage
81+
## Usage
7882

7983
```yaml
8084
- uses: dorny/paths-filter@v2
@@ -139,26 +143,27 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob
139143
working-directory: ''
140144
141145
# Personal access token used to fetch a list of changed files
142-
# from Github REST API.
146+
# from GitHub REST API.
143147
# It's only used if action is triggered by a pull request event.
144-
# Github token from workflow context is used as default value.
148+
# GitHub token from workflow context is used as default value.
145149
# If an empty string is provided, the action falls back to detect
146150
# changes using git commands.
147151
# Default: ${{ github.token }}
148152
token: ''
149153
```
150154

151155
## Outputs
156+
152157
- For each filter, it sets output variable named by the filter to the text:
153-
- `'true'` - if **any** of changed files matches any of filter rules
154-
- `'false'` - if **none** of changed files matches any of filter rules
158+
- `'true'` - if **any** of changed files matches any of filter rules
159+
- `'false'` - if **none** of changed files matches any of filter rules
155160
- For each filter, it sets an output variable with the name `${FILTER_NAME}_count` to the count of matching files.
156161
- 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.
157162
- `changes` - JSON array with names of all filters matching any of the changed files.
158163

159-
# Examples
164+
## Examples
160165

161-
## Conditional execution
166+
### Conditional execution
162167

163168
<details>
164169
<summary>Execute <b>step</b> in a workflow job only if some file in a subfolder is changed</summary>
@@ -193,6 +198,7 @@ jobs:
193198
if: steps.filter.outputs.backend == 'true' || steps.filter.outputs.frontend == 'true'
194199
run: ...
195200
```
201+
196202
</details>
197203

198204
<details>
@@ -236,6 +242,7 @@ jobs:
236242
- uses: actions/checkout@v2
237243
- ...
238244
```
245+
239246
</details>
240247

241248
<details>
@@ -271,9 +278,10 @@ jobs:
271278
- uses: actions/checkout@v2
272279
- ...
273280
```
281+
274282
</details>
275283

276-
## Change detection workflows
284+
### Change detection workflows
277285

278286
<details>
279287
<summary><b>Pull requests:</b> Detect changes against PR base branch</summary>
@@ -294,6 +302,7 @@ jobs:
294302
with:
295303
filters: ... # Configure your filters
296304
```
305+
297306
</details>
298307

299308
<details>
@@ -319,6 +328,7 @@ jobs:
319328
base: develop # Change detection against merge-base with this branch
320329
filters: ... # Configure your filters
321330
```
331+
322332
</details>
323333

324334
<details>
@@ -346,6 +356,7 @@ jobs:
346356
base: ${{ github.ref }}
347357
filters: ... # Configure your filters
348358
```
359+
349360
</details>
350361

351362
<details>
@@ -375,9 +386,10 @@ jobs:
375386
base: HEAD
376387
filters: ... # Configure your filters
377388
```
389+
378390
</details>
379391

380-
## Advanced options
392+
### Advanced options
381393

382394
<details>
383395
<summary>Define filter rules in own file</summary>
@@ -389,6 +401,7 @@ jobs:
389401
# Path to file where filters are defined
390402
filters: .github/filters.yaml
391403
```
404+
392405
</details>
393406

394407
<details>
@@ -409,6 +422,7 @@ jobs:
409422
- *shared
410423
- src/**
411424
```
425+
412426
</details>
413427

414428
<details>
@@ -434,10 +448,10 @@ jobs:
434448
addedOrModifiedAnchors:
435449
- added|modified: *shared
436450
```
437-
</details>
438451
452+
</details>
439453
440-
## Custom processing of changed files
454+
### Custom processing of changed files
441455
442456
<details>
443457
<summary>Passing list of modified files as command line args in Linux shell</summary>
@@ -462,6 +476,7 @@ jobs:
462476
if: ${{ steps.filter.outputs.markdown == 'true' }}
463477
run: npx textlint ${{ steps.filter.outputs.markdown_files }}
464478
```
479+
465480
</details>
466481
467482
<details>
@@ -486,11 +501,13 @@ jobs:
486501
with:
487502
files: ${{ steps.filter.outputs.changed_files }}
488503
```
504+
489505
</details>
490506
491-
# See also
507+
## See also
508+
492509
- [test-reporter](https://github.com/dorny/test-reporter) - Displays test results from popular testing frameworks directly in GitHub
493510
494-
# License
511+
## License
495512
496513
The scripts and documentation in this project are released under the [MIT License](https://github.com/dorny/paths-filter/blob/master/LICENSE)

0 commit comments

Comments
 (0)