Search code examples
githubcontinuous-integrationgithub-actions

How to run GitHub Actions workflow only if the pushed files are in a specific folder


I have a folder structure that looks something like this.

- folder1
  - file1
  - *other files*
- folder2
  - file1
  - *other files*
- .gitignore
- package.json
- *other files*

I want to run my GitHub Actions workflow on push, only if any of the changed/pushed files are located in the folder1 directory/folder.


Solution

  • The normal syntax involves a path filter

    on:
      push:
        paths:
          - folder1/**
    

    If that is not enough, you also have the GitHub Action Path Filter.