From d99aa3ed71460c8f692dd39da4a09944ae919ca5 Mon Sep 17 00:00:00 2001 From: Vanessasaurus <814322+vsoch@users.noreply.github.com> Date: Sat, 2 Oct 2021 22:40:48 -0600 Subject: [PATCH] Adding quick option to be able to specify a GitHub enterprise url (#80) * adding quick option to be able to specify a GitHub enterprise url Signed-off-by: vsoch * Use GITHUB_API_URL instead Co-authored-by: Tobias * Update README.md * Update pull-request.py Co-authored-by: vsoch Co-authored-by: Tobias --- README.md | 8 ++++---- pull-request.py | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2d8d756..fe4ffb6 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,10 @@ Unlike standard actions, this action just uses variables from the environment. | PULL_REQUEST_ASSIGNEES | A list (string with spaces) of users to assign | 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 | -| 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 | -| PULL_REQUEST_UPDATE | If the pull request already exists, update it | unset | -| PULL_REQUEST_STATE | If `PULL_REQUEST_UPDATE` is true, update to this state (open, closed) | open | +| PASS_ON_ERROR | Instead of failing on an error response, pass | false | unset | +| PASS_IF_EXISTS | Instead of failing if the pull request already exists, pass | false | unset | +| PULL_REQUEST_UPDATE | If the pull request already exists, update it | false | unset | +| PULL_REQUEST_STATE | If `PULL_REQUEST_UPDATE` is true, update to this state (open, closed) | false |open | 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 diff --git a/pull-request.py b/pull-request.py index f95ad1d..98971ee 100755 --- a/pull-request.py +++ b/pull-request.py @@ -235,8 +235,7 @@ def find_pull_request(listing, source): def find_default_branch(): - """Find default branch for a repo (only called if branch not provided) - """ + """Find default branch for a repo (only called if branch not provided)""" response = requests.get(REPO_URL) # Case 1: 404 might need a token @@ -283,7 +282,9 @@ def add_reviewers(entry, reviewers, team_reviewers): ################################################################################ API_VERSION = "v3" -BASE = "https://api.github.com" + +# Allow for a GitHub enterprise URL +BASE = os.environ.get("GITHUB_API_URL") or "https://api.github.com" PR_TOKEN = os.environ.get("PULL_REQUEST_TOKEN") or get_envar("GITHUB_TOKEN") PR_REPO = os.environ.get("PULL_REQUEST_REPOSITORY") or get_envar("GITHUB_REPOSITORY")