Add an override for the base branch

This commit is contained in:
Peter Evans 2019-10-21 20:17:31 +09:00
parent c5ff844b40
commit 8c2a43987b
2 changed files with 8 additions and 2 deletions

View file

@ -184,12 +184,17 @@ if skip_ignore_event or not ignore_event(event_name, event_data):
# Set the base branch
github_ref = os.environ['GITHUB_REF']
if github_ref.startswith('refs/pull/'):
# Switch to the merging branch instead of the merge commit
base = os.environ['GITHUB_HEAD_REF']
# Reset to the merging branch instead of the merge commit
repo.git.checkout(base)
else:
base = github_ref[11:]
# Optional base override
base = os.getenv('PULL_REQUEST_BASE', base)
# Checkout the base branch
repo.git.checkout(base)
# Skip if the current branch is a PR branch created by this action
if base.startswith(branch):
print("Branch '%s' was created by this action. Skipping." % base)