Skip to content

Access to target branch on push #25813

Discussion options

You must be logged in to vote

Base ref will give you the information about the base of a pull request - yes.  This information is provided to you in the github context.  So you can use this either as a variable in your workflow, or an environment variable in workflow executions.  For example:

run: |
  echo "Base ref is $GITHUB_BASE_REF"

Or to use this as a test for a step:

run: echo "Hello, world"
if: github.base_ref == 'refs/heads/master'

But if your goal is to create a workflow that only runs for pushes on a PR with a specific target branch then you can codify that in the trigger for the entire workflow:

on:
  pull_request:
    branches:
    - master

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants