Skip to content

Commit

Permalink
pr_review_queue.py: add support for passing env to GHApi
Browse files Browse the repository at this point in the history
Github API library supports handling of environment
variables, so we'll support it for easier local setup.
  • Loading branch information
schuellerf committed Dec 10, 2024
1 parent f86f556 commit 0a7c863
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ The Slack member ids are encrypted and can be decrypted or re-encrypted using th
## Usage

`python3 pr_review_queue.py --github-token $GITHUB_TOKEN --org $GITHUB_ORG --repo $GITHUB_REPO`

alternatively you can also set `GITHUB_TOKEN` as environment variable and call

`python3 pr_review_queue.py --org $GITHUB_ORG --repo $GITHUB_REPO`

10 changes: 9 additions & 1 deletion pr_review_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,15 @@ def create_pr_review_queue(pull_request_list):
def main():
"""Create a pull request review queue"""
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--github-token", help="Set a token for github.com", required=True)

# GhApi() supports pulling the token out of the env - so if it's
# set - we don't need to force this in the params
if os.getenv("GITHUB_TOKEN") is None:
token_arg_required=True
else:
token_arg_required=False

parser.add_argument("--github-token", help="Set a token for github.com", required=token_arg_required)
parser.add_argument("--org", help="Set an organisation on github.com", required=True)
parser.add_argument("--repo", help="Set a repo in `--org` on github.com", required=False)
parser.add_argument("--queue", help="Create a review queue", default=True,
Expand Down

0 comments on commit 0a7c863

Please sign in to comment.