Github Action: Trigger a workflow on changes to path and push to master

I want to trigger a build workflow when there is a change in a specified path in any commit pushed to any branch and also when a PR/commit is merged/pushed to master.

I tried defining it this way

on:
  push:
    branches: 
      - master
    paths: 'mypath/**'

When something is merged/pushed to master this doesn’t trigger the workflow. Is there any war around this?

@Aka-shi,

There are some build-in events for pull request you can use to trigger workflows.

According to your requests, you can set the trigger events in the workflow file like as below:

on: 
  push:
    paths:
      - 'mypath/**'

  pull_request:
    branches: 
      - master

And you also need to store this workflow file in the “.github/workflows” directory in every branch.