Skip to content

What’s the best way to trigger a GitHub Actions workflow only when specific files or folders change? #164673

Answered by AmanT776
Amanuel776 asked this question in Actions
Discussion options

You must be logged in to vote

GitHub Actions Path Filtering for Monorepos

This is about GitHub Actions' path filtering capabilities, specifically for monorepo workflows. Let me break down the best practices and considerations:

Optimal Path Filtering Setup

For your monorepo, you can optimize path filtering like this:

on:
  push:
    paths:
      - 'backend/**'
      - 'backend/*'
  pull_request:
    paths:
      - 'backend/**'
      - 'backend/*'

Key Considerations

  1. Double Asterisk (**) vs Single Asterisk (*):

    • backend/** matches all files in backend and its subdirectories
    • backend/* matches only files directly in the backend directory
  2. Pull Request Behavior:

    • Path filtering works with pull requests, but only for the f…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Amanuel776
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 Misc General discussions about GitHub Actions that don't fit other found themes.
3 participants