Skip to content

Access owner and branch of a PR head within GitHub Actions #25908

Answered by BrightRan
pmeier asked this question in Actions
Discussion options

You must be logged in to vote

@pmeier,

You can use the expression (github.event.pull_request.head.repo.owner.login) to get the owner of the head repository from the github context.

on: pull_request
jobs:
  job1:
    . . .
    steps:
      - name: get the owner of the head repository
        run: echo "head owner = ${{ github.event.pull_request.head.repo.owner.login }}"

Of course, if you feel that this expression is too long, you can map it as a environment variable with a shorter name.

on: pull_request

env:
HEAD_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}

jobs:
job1:
. . .
steps:
- name: get the owner of the head repository
run: echo "head owner = ${{ env.HEAD_OWNER }}"

About the default environmen…

Replies: 6 comments

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
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
2 participants