Search code examples
githubgithub-actionsbuilding-github-actions

How to trigger workflow action if it touches certain file or is a Pull Request with a certan file


I have the following action:

name: Run after changing anything in myPath package
on:
  pull_request:
  push:
    paths:
      - 'myPath/**'

This action runs when something is pushed under myPath but also on any pull request.

How I can limit this action to pull requests that contain changes under myPath?


Solution

  • You have to repeat paths for each event type.

    name: Run after changing anything in myPath package
    on:
      pull_request:
        paths:
          - 'myPath/**'
      push:
        paths:
          - 'myPath/**'