I'm struggle to get the behaviour I want with GitHub Actions.
What I'm after is:
This is the YAML I believe should work for the push workflow:
on: push: tags-ignore: - '*.*' # We don't want this to run on release paths-ignore: # Don't trigger on files that are updated by the CI - pyproject.toml - setup.py - README.rst
I have the following for the release workflow:
on: release: types: [published]
However, given the above configuration, NO workflows are triggered when I push a commit.
If I remove the tags-ignore element, then workflows trigger, but when I do a release, the "push" workflow still triggers as well (I believe because it results in a tag push).
I haven't yet been at all able to make the paths-ignore syntax work.
Some assistance would be greatly appreciated.
Hi @stevegore ,
There are several notes need you pay attention to:
If you want your "push" workflow can run for specific branches and specific tags, you need to add both branches filter and tags filter.
1) With the following filters, the workflow will run when push commits to the master branch, or when push to the tags that do not match the pattern in tags-ignore.
2) With the following filters, the workflow will run when push commits to any branch, or when push to the tags that do not match the pattern in tags-ignore.
Thanks for replying.
I managed to get something close to what I'm after using:
on: push: branches: - '**' tags-ignore: - '*.*'
However, paths-ignore is still not working for me. Changes to the ignored paths are still triggering actions. This is the YAML, including the paths-ignore:
on: push: branches: - '**' tags-ignore: - '*.*' paths-ignore: - README.rst
Changes to README.rst are still triggering a build. Should I raise an issue?
@stevegore Can you confirm whether the ignored file README.rst is located at the root directory of the repository?
If it is in a sub-folder of the root directory, not the root directory, the syntax you used to reference the ignored file is correct. You should provide the complete relative path of the ignored file.
root └ docs └ README.rst
paths-ignore: - docs/README.rst
I'm finding the implicit rules quite hard to understand, perhaps because the way they are worded, or because the language used is not the one I can find in the git docs, or perhaps I just don't know enough about git internals – even though I would consider myself an experienced git user.
Take the following statement:
> If only define only tags filter (tags/ tags-ignore) or only branches filter (branches/ branches-ignore) for on.push, the workflow won't run for events affecting the undefined Git ref.
1. Does "events affecting the undefined Git ref" refer to events which don't have a ref associated? Is there a thing as a undefined git ref?
2. Isn't it the case that "the workflow won't run for events affecting the undefined Git ref", even if both tags filter and braches filter are defined at the same time? After all, if there is no branch ref, and no tag ref, why would the workflow be triggered?
Clarification on both this points would be greatly appreciated. Thank you in advance.
@stevegore did you ever determine what the problem was with the `paths-ignore` for the `README.md`?
I ask because the following stanza still results in the workflow running even though the only change was to the `README.md`.