| You cannot use `paths` and `paths-ignore` to filter the same event in a single workflow. If you want to both include and exclude path patterns for a single event, use the `paths` filter prefixed with the `!` character to indicate which paths should be excluded. | |
| If you define a path with the `!` character, you must also define at least one path without the `!` character. If you only want to exclude paths, use `paths-ignore` instead. | |
| The order that you define `paths` patterns matters: | |
| * A matching negative pattern (prefixed with `!`) after a positive match will exclude the path. | |
| * A matching positive pattern after a negative match will include the path again. | |
| This example runs anytime the `push` event includes a file in the `sub-project` directory or its subdirectories, unless the file is in the `sub-project/docs` directory. For example, a push that changed `sub-project/index.js` or `sub-project/src/index.js` will trigger a workflow run, but a push changing only `sub-project/docs/readme.md` will not. | |
| ```yaml | |
| on: | |
| push: | |
| paths: | |
| - 'sub-project/**' | |
| - '!sub-project/docs/**' | |
| ``` | |