How can I trigger a GitHub Action only when a file in a specific folder changes? #164906
-
Why are you starting this discussion?Question What GitHub Actions topic or product is this about?Actions Runner Discussion DetailsHi all, I’ve tried using paths in the workflow trigger like this: on:
push:
paths:
- 'src/**' But it still seems to run even when changes are made outside the src/ folder. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @Ghartic-Dere, Your workflow config using
on:
push:
paths:
- 'src/**'
pull_request:
paths:
- 'src/**' This setup will trigger the workflow only when files inside the
Reference: If it’s still running unexpectedly, feel free to share your full workflow YAML and more context so we can help you debug further! Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Oh, @turtle-key, thanks for the suggestions! |
Beta Was this translation helpful? Give feedback.
Hi @Ghartic-Dere,
Your workflow config using
paths
is almost correct and should generally work as expected. Here are a few notes and tips to help you troubleshoot and clarify:Your YAML should look like this:
This setup will trigger the workflow only when files inside the
src/
directory are changed, for bothpush
andpull_request
events.on: push:
withoutpaths
) that could fire on any change.