Skip to content

Commit a0a54b6

Browse files
committed
Feature: add should_add_reviewers input
1 parent 12dc423 commit a0a54b6

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

action.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ inputs:
1818
description: labels for PR, as comma-separated list
1919
required: false
2020
default: ""
21+
should_add_reviewers:
22+
description: whether to add reviewers to PR
23+
required: false
24+
default: "true"
2125
required_reviewers:
2226
description: reviewers required for all PRs
2327
required: false
@@ -62,6 +66,7 @@ runs:
6266
--head-branch=${{ env.DEPLOYMENT_BRANCH }} \
6367
--base-branch=${{ inputs.target }} \
6468
--required-reviewers=${{ inputs.required_reviewers }} \
69+
--should-add-reviewers=${{ inputs.should_add_reviewers }} \
6570
)" >> $GITHUB_ENV
6671
shell: bash
6772

deploy_bot/get_reviewers.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Dict, List, Set
33

44
import requests
5+
from six import b
56

67

78
GITHUB_TOKEN: str = os.getenv("GITHUB_TOKEN")
@@ -49,6 +50,12 @@ def find_contributors_to_branch(repository: str, head_branch: str, base_branch:
4950
dest="base_branch",
5051
help="base branch for comparison",
5152
)
53+
parser.add_argument(
54+
"--should-add-reviewers",
55+
dest="should_add_reviewers",
56+
help="if should add reviewers to PR",
57+
type=bool,
58+
)
5259
parser.add_argument(
5360
"--required-reviewers",
5461
dest="required_reviewers",
@@ -57,11 +64,12 @@ def find_contributors_to_branch(repository: str, head_branch: str, base_branch:
5764

5865
args = parser.parse_args()
5966

60-
# find contributors to branch
61-
contributors: Set[str] = find_contributors_to_branch(args.repository, args.head_branch, args.base_branch)
67+
if args.should_add_reviewers:
68+
# find contributors to branch
69+
contributors: Set[str] = find_contributors_to_branch(args.repository, args.head_branch, args.base_branch)
6270

63-
# output reviewers as comma delimited list
64-
reviewers = contributors | set(args.required_reviewers.split(","))
65-
print(",".join(reviewers))
71+
# output reviewers as comma delimited list
72+
reviewers = contributors | set(args.required_reviewers.split(","))
73+
print(",".join(reviewers))
6674

6775
exit(0)

0 commit comments

Comments
 (0)