Skip to content

How can I trigger a GitHub Action only when a file in a specific folder changes? #164906

Closed Answered by turtle-key
Ghartic-Dere asked this question in Actions
Discussion options

You must be logged in to vote

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:

  1. Correct Usage Example
    Your YAML should look like this:
on:
  push:
    paths:
      - 'src/**'
  pull_request:
    paths:
      - 'src/**'

This setup will trigger the workflow only when files inside the src/ directory are changed, for both push and pull_request events.

  1. Why might it still run on other changes?
  • Ensure there aren’t other triggers in your workflow (like on: push: without paths) that could fire on any change.
  • Double-check for indentation or YAML formatting errors.
  • If you have multiple workflows, mak…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Ghartic-Dere
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Question Ask and answer questions about GitHub features and usage Actions Runner For issues and discussions related to the Actions Runner project Misc General discussions about GitHub Actions that don't fit other found themes.
2 participants