'Github Action trigger with path and on working directory

I have the following github action :

on:
  pull_request:
    paths:
      - 'path1/**'
      - 'path2/**'
  jobs:
    example:
       name: "example"
       runs-on: ubuntu-latest

    defaults:
     run:
       working-directory: ./path/to/my/working_directory

I am trying to trigger the flow only when a file is pushed on the following directories

  • 'path1/**'
  • 'path2/**'

but it seems that the flow is triggered every time even if i push something in other directories (ex. path3/**).

Could it be because of the working-directory because path1 and path2 are in the root directory.

Any ideas will be appreciated it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source