Reputation: 65861
I'm trying to test a PR handling action on Github.
For that I'm creating a PR in my own repo and trying to use ${{ github.base_ref }}
, but it is empty.
This help page says that GITHUB_BASE_REF
is only available for PRs from forks.
Is there a way to get the target branch for a PR event, regardless of whether it is from a forked PR or not? Or a way to address the latter case specifically.
P.S. What I'm really trying to do is to get a list of changed files in the PR. What I have works for pushes but not for PRs:
git diff-tree --no-commit-id --name-only -r ${{ github.event.before }} ${{ github.sha }}
Upvotes: 4
Views: 2629
Reputation: 42260
This should work regardless of whether it's raised from a fork or not.
${{ github.event.pull_request.base.ref }}
By the way, you can add a step in your workflow to dump the github
context object to see all available properties.
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
Upvotes: 3