GitHub Actions Day 10: Path Triggers
This is day 10 of my GitHub Actions Advent Calendar. If you want to see the whole list of tips as they're published, see the index.
We saw earlier that we can limit workflow runs based on branch
filters. For workflows
triggered by a push
or a pull_request
, you can limit them so that
they only trigger when a particular branch is pushed to, or a pull
request is opened against a particular branch.
You can also limit these workflows so that they trigger only when a particular path is pushed.
This is very useful if you have some automation that runs when you check something in. For example: in one of my open source projects, we publish our documentation to our website every time we merge a commit into the master branch. But we only want to run that workflow when the documentation actually changes.
In this case, we want to run when anything in the docs
directory
is changed in the master
branch. We can use a wildcard as
part of our path filter:
Now we have a workflow that will run our publish_docs.sh
script
whenever we create a new change to a file in our docs
folder and
merge that change into the master
branch.