I wanted to trigger the pipeline when any file is changed in the directory or subdirectories of folder /ProjectA/ except /ProjectA/sub-dir-a.
I added the below event to achieve the results, however, it throws an error saying Path and Path-ignore cannot be added in the same event.
on:
push:
branches: [ master ]
paths: "ProjectA/**"
paths-ignore: " ProjectA/sub-dir-a /**"
Error Received:

Further, If I change an event to include "paths" only, it triggers the pipeline even when any files are changed in the subfolder too.
I was looking for an option to exclude sub directory.
As you can see you cannot mix the paths with paths-ignore but if you look at the filter pattern cheat sheet and later at the pattern to match file paths section you can see you can also negate patterns:
Using an exclamation mark (
!) in front of a pattern negates it. When a file matches a pattern and also matches a negative pattern defined later in the file, the file will not be included.
Having that in mind you can try with:
on:
push:
branches:
- master
paths:
- "ProjectA/**"
- "!ProjectA/sub-dir-a/**"
The example from the documentation covers exactly your case.
This is how I managed to do for a Github Action while building a Docker CI/CD pipeline. I wanted to avoid docker builds for README files (not a sub-folder as asked in the OP) so this is what I did
on:
push:
branches:
- main
paths:
- "java/**"
- "!**/README.md"
pull_request:
branches:
- main
This worked like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With