The best practice of Github actions on a MonoRepo like repository

I have some repositories which include more than one project, but I want to make every project apply its own build lifecycle, I created a standalone Github actions workflow file for each project.

For example, spring-graphql-sample/.github/workflows at master · hantsy/spring-graphql-sample · GitHub

In the workflow file, I used the paths attribute on push to differentiate the projects.

      - "dgs-client/**"
    branches: [ master ]
    branches: [ master ]

The problem is when pushing codes to master branch directly, it worked as expected, but when contributing codes via PRs, it will trigger all workflows.

I have to add another paths on the pull_request event ?

Yes, you need to specify paths for the pull_request event as well. It’s actually the only other event that supports paths: Workflow syntax for GitHub Actions - GitHub Docs