Trigger action on specific source branch name

We have a branch model with feature branches, develop, staging (for testing) and master for release. Now we have an action for the Release notes, which creates a Pull Request with the actual release notes when pushing to staging or master.

But the action should only run when we push a Pull Request from develop into staging and staging into master, but not when pushing from the release notes branch into staging or master, because then we always have a new created Pull Request with the release notes. Is this possible? Thank you!

Hi @benwick91,

You can use on.pull_request.branches to limit the base branch.
And add job level if expression to check ‘github.head_ref’, if it’s not source branch, skip the job.

Code sample as below:

on:
  pull_request:
    branches:            # limit base branch to staging and master branch.
      - staging
      - master
jobs:
  prcheck:
    if: github.head_ref=='develop' || github.head_ref=='staging'   # check the source branch, skip the job if it's not correct.
    ......

Thanks