How to trigger a GitHub Actions workflow only on specific file changes? #175724
Why are you starting this discussion?Question What GitHub Actions topic or product is this about?Workflow Deployment Discussion DetailsHey all, I want to set up a GitHub Actions workflow that only runs when certain files or folders are modified—like only when code inside the /src directory changes, and not for changes to documentation or config files. What’s the best way to configure this in the workflow YAML? Are there built-in filters or conditions I can use to optimize workflow runs and save CI resources? Any sample configurations or tips on handling this would be really helpful! |
Answered by
tranquillite-007
Oct 3, 2025
Replies: 2 comments
This comment was marked as off-topic.
This comment was marked as off-topic.
|
What about those that are required checks? We have seen that the required configured checks don't take into account this tho. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can definitely set up your GitHub Actions workflow to run only when specific files or directories change, which is a great way to save time and resources. The easiest way to do this is by using the paths or paths-ignore filters under the on event in your workflow YAML. For example, if you want the workflow to trigger only when files inside the /src folder change, you’d add something like paths: ['src/**'] to your push or pull_request triggers. This way, changes to other parts of the repo, like documentation or config files, won’t start the workflow unnecessarily. You can also use paths-ignore if you want the workflow to run on every change except certain files or folders. This filteri…