Combine path and tags conditionals #26273
-
How is the logic when combining conditonals for push to restrict paths and tags or branches? In my specific case I want to limit a workflow to only a specific list of paths, but I want to ensure it always runs on a tag. Interestingly if I only do something like this:
The behavior is:
Is my observation correct? Can I rely on the workflow being run on every tag push? And what happens if I define both paths and tags, e.g:
The expecation would be that this runs on any push that changes src/** and also on an tag release-* independent of the paths in the changed commit. Is this correct? If not, how could I achieve this behavior? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Thank you for posting this question in Github Community forum. Based on your requirement: The expecation would be that this runs on any push that changes src/** and also on an tag release-* independent of the paths in the changed commit. You can add branches filter with paths and tags together:
Please note that: 1. Path filters are not evaluated for pushes to tags. You can found this sentence here. This could explain that when you use path filter only, when you tag a commit that does not contain changes to src/** the workflow also runs on pushing this tag. on: push: paths: - ‘src/**’ 2. If you only define only ** tags or only branches **, the workflow won’t run for events affecting the undefined Git ref. You can found this sentence here. When you just add paths and tags filter to on push event, tags filter will stop the workflow to be triggered by pushing to branches. So I suggest you to add branches filter. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot, this fuly answers my questions. I missed that part that path filters are ignored for tag pushes, but it makes sense and really helps in my case. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Thank you for posting this question in Github Community forum.
Based on your requirement: The expecation would be that this runs on any push that changes src/** and also on an tag release-* independent of the paths in the changed commit.
You can add branches filter with paths and tags together:
Please note that:
1. Path filters are not evaluated for pushes to tags. You can found this sentence here.
This could explain that when you use path filter only, when you tag a commit that does not contain changes to src/** the workflow also runs on pushing this tag.
on:
push:
paths:
- ‘src/**’