I have the following config in my yml file:
name: code pipeline
run-name: code pipeline run by ${{ github.actor }}
on:
push:
paths:
- my-code/**
- scripts/some-other-script.py
- .github/workflows/my-workflow.yml
And for some reason that workflow is always triggered even if I am just pushing a new tag. This is more a minor annoyance than a blocker, but I thought it would be nice to understand this better, because I am obviously missing something here. Thank you for your help!
I would expect that this workflow is only triggered on code changes anywhere in the given paths.
As per actions docs:
When using the push event, you can configure a workflow to run on specific branches or tags.
If you define only tags
/tags-ignore
or only branches
/branches-ignore
, the workflow won't run for events affecting the undefined Git ref. If you define neither tags
/tags-ignore
or branches
/branches-ignore
, the workflow will run for events affecting either branches or tags. If you define both branches
/branches-ignore
and paths, the workflow will only run when both filters are satisfied.
At the same time, path filters are not evaluated for pushes of tags.
It means that if you want to trigger the workflow only for code changes, you need to add the explicit parameter branches
, e.g. like this:
name: code pipeline
run-name: code pipeline run by ${{ github.actor }}
on:
push:
branches:
- '**'
paths:
- my-code/**
- scripts/some-other-script.py
- .github/workflows/my-workflow.yml
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