Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c39853dfde |
@@ -46,14 +46,16 @@ Unlike standard actions, this action just uses variables from the environment.
|
|||||||
| PULL_REQUEST_REVIEWERS | A list (string with spaces) of users to assign review | false | unset |
|
| PULL_REQUEST_REVIEWERS | A list (string with spaces) of users to assign review | false | unset |
|
||||||
| PULL_REQUEST_TEAM_REVIEWERS | A list (string with spaces) of teams to assign review | false | unset |
|
| PULL_REQUEST_TEAM_REVIEWERS | A list (string with spaces) of teams to assign review | false | unset |
|
||||||
| PASS_ON_ERROR | Instead of failing on an error response, pass | unset |
|
| PASS_ON_ERROR | Instead of failing on an error response, pass | unset |
|
||||||
|
| PASS_IF_EXISTS | Instead of failing if the pull request already exists, pass | unset |
|
||||||
|
|
||||||
For `PULL_REQUEST_DRAFT`, `PASS_ON_ERROR`, and `MAINTAINER_CANT_MODIFY`, these are
|
For `PULL_REQUEST_DRAFT`, `PASS_ON_ERROR`, `PASS_IF_EXISTS`, and `MAINTAINER_CANT_MODIFY`, these are
|
||||||
treated as environment booleans. If they are defined in the environment, they trigger the
|
treated as environment booleans. If they are defined in the environment, they trigger the
|
||||||
"true" condition. E.g.,:
|
"true" condition. E.g.,:
|
||||||
|
|
||||||
- Define `MAINTAINER_CANT_MODIFY` if you don't want the maintainer to be able to modify the pull request.
|
- Define `MAINTAINER_CANT_MODIFY` if you don't want the maintainer to be able to modify the pull request.
|
||||||
- Define `PULL_REQUEST_DRAFT` if you want the PR to be a draft.
|
- Define `PULL_REQUEST_DRAFT` if you want the PR to be a draft.
|
||||||
- Define `PASS_ON_ERROR` if you want the PR to not exit given any non 200/201 response.
|
- Define `PASS_ON_ERROR` if you want the PR to not exit given any non 200/201 response.
|
||||||
|
- Define `PASS_IF_EXISTS` if you want the PR to not exit given the pull request is already open.
|
||||||
|
|
||||||
For `PULL_REQUEST_ASSIGNEES`, `PULL_REQUEST_REVIEWERS`, and `PULL_REQUEST_TEAM_REVIEWERS`
|
For `PULL_REQUEST_ASSIGNEES`, `PULL_REQUEST_REVIEWERS`, and `PULL_REQUEST_TEAM_REVIEWERS`
|
||||||
you can provide a string of one or more GitHub usernames (or team names) to
|
you can provide a string of one or more GitHub usernames (or team names) to
|
||||||
|
|||||||
@@ -73,13 +73,14 @@ def create_pull_request(
|
|||||||
):
|
):
|
||||||
|
|
||||||
# Check if the branch already has a pull request open
|
# Check if the branch already has a pull request open
|
||||||
|
params = {"base": target, "head": source, "state": "open"}
|
||||||
data = {"base": target, "head": source, "body": body}
|
data = {"base": target, "head": source, "body": body}
|
||||||
print("Data for checking if pull request exists: %s" % data)
|
print("Params for checking if pull request exists: %s" % params)
|
||||||
response = requests.get(PULLS_URL, json=data)
|
response = requests.get(PULLS_URL, params=params)
|
||||||
|
|
||||||
# Case 1: 404 might warrant needing a token
|
# Case 1: 404 might warrant needing a token
|
||||||
if response.status_code == 404:
|
if response.status_code == 404:
|
||||||
response = requests.get(PULLS_URL, json=data, headers=HEADERS)
|
response = requests.get(PULLS_URL, params=params, headers=HEADERS)
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
abort_if_fail(
|
abort_if_fail(
|
||||||
"Unable to retrieve information about pull requests: %s: %s"
|
"Unable to retrieve information about pull requests: %s: %s"
|
||||||
@@ -96,9 +97,15 @@ def create_pull_request(
|
|||||||
print("Pull request from %s to %s is already open!" % (source, target))
|
print("Pull request from %s to %s is already open!" % (source, target))
|
||||||
is_open = True
|
is_open = True
|
||||||
|
|
||||||
|
# Does the user want to pass if the pull request exists?
|
||||||
|
if os.environ.get("PASS_IF_EXISTS"):
|
||||||
|
print("PASS_IF_EXISTS is set, exiting with success status.")
|
||||||
|
sys.exit(0)
|
||||||
|
break
|
||||||
|
|
||||||
# Option 2: Open a new pull request
|
# Option 2: Open a new pull request
|
||||||
if not is_open:
|
if not is_open:
|
||||||
print("%s does not have a pull request open, continuing!" % source)
|
print("No pull request from %s to %s is open, continuing!" % (source, target))
|
||||||
|
|
||||||
# Post the pull request
|
# Post the pull request
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
Reference in New Issue
Block a user