Navigation Menu

Skip to content

Trigger action on specific source branch name #26082

Answered by weide-zhou
Benwick91 asked this question in Actions
Discussion options

You must be logged in to vote

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants