Add an override for the base branch
This commit is contained in:
parent
c5ff844b40
commit
8c2a43987b
2 changed files with 8 additions and 2 deletions
|
@ -51,6 +51,7 @@ These variables are *all optional*. If not set, sensible default values will be
|
|||
| `PULL_REQUEST_TEAM_REVIEWERS` | A comma separated list of GitHub teams to request a review from. | none |
|
||||
| `PULL_REQUEST_MILESTONE` | The number of the milestone to associate this pull request with. | none |
|
||||
| `PULL_REQUEST_BRANCH` | The branch name. See **Branch naming** below for details. | `create-pull-request/patch` |
|
||||
| `PULL_REQUEST_BASE` | Overrides the base branch. **Use with caution!** | Defaults to the currently checked out branch. |
|
||||
| `BRANCH_SUFFIX` | The branch suffix type. Valid values are `short-commit-hash`, `timestamp`, `random` and `none`. See **Branch naming** below for details. | `short-commit-hash` |
|
||||
|
||||
**Output environment variables**
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue