Skip to content

Commit

Permalink
Feature: add should_add_reviewers input
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansingman committed Aug 21, 2024
1 parent 12dc423 commit a0a54b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
description: labels for PR, as comma-separated list
required: false
default: ""
should_add_reviewers:
description: whether to add reviewers to PR
required: false
default: "true"
required_reviewers:
description: reviewers required for all PRs
required: false
Expand Down Expand Up @@ -62,6 +66,7 @@ runs:
--head-branch=${{ env.DEPLOYMENT_BRANCH }} \
--base-branch=${{ inputs.target }} \
--required-reviewers=${{ inputs.required_reviewers }} \
--should-add-reviewers=${{ inputs.should_add_reviewers }} \
)" >> $GITHUB_ENV
shell: bash
Expand Down
18 changes: 13 additions & 5 deletions deploy_bot/get_reviewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Dict, List, Set

import requests
from six import b


GITHUB_TOKEN: str = os.getenv("GITHUB_TOKEN")
Expand Down Expand Up @@ -49,6 +50,12 @@ def find_contributors_to_branch(repository: str, head_branch: str, base_branch:
dest="base_branch",
help="base branch for comparison",
)
parser.add_argument(
"--should-add-reviewers",
dest="should_add_reviewers",
help="if should add reviewers to PR",
type=bool,
)
parser.add_argument(
"--required-reviewers",
dest="required_reviewers",
Expand All @@ -57,11 +64,12 @@ def find_contributors_to_branch(repository: str, head_branch: str, base_branch:

args = parser.parse_args()

# find contributors to branch
contributors: Set[str] = find_contributors_to_branch(args.repository, args.head_branch, args.base_branch)
if args.should_add_reviewers:
# find contributors to branch
contributors: Set[str] = find_contributors_to_branch(args.repository, args.head_branch, args.base_branch)

# output reviewers as comma delimited list
reviewers = contributors | set(args.required_reviewers.split(","))
print(",".join(reviewers))
# output reviewers as comma delimited list
reviewers = contributors | set(args.required_reviewers.split(","))
print(",".join(reviewers))

exit(0)

0 comments on commit a0a54b6

Please sign in to comment.