Skip to content

Commit

Permalink
feat: make team reviews a parameter (#14)
Browse files Browse the repository at this point in the history
Previously, all PRs automatically added the sourcegrapm/team/release
reviewer to PRs. That worked fine while we were only using this on
Monorepo, but now we're expanding usage to Cody, Jetbrains and the
Deploy-* repos. Cody and Jetbrains particularly do not have the release
team as collaborator which caused errors while using this automation.

We're keeping the default the same with this change, but now we can
optionally override the default to change the team, or remove it
entirely (setting teamReviews = "").
  • Loading branch information
Chickensoupwithrice authored Nov 15, 2024
1 parent 06d6f0a commit c7f54dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inputs:
- base: backport PR's base branch
- number: original PR's number
default: "backport-<%= number %>-to-<%= base %>"
team_reviews:
description: Whether to request reviews from the team.
required: false
default: "release"
label_pattern:
description: >
The regular expression pattern that PR labels will be tested on to decide whether the PR should be backported and where.
Expand Down
7 changes: 6 additions & 1 deletion src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const backportOnce = async ({
merged_by,
owner,
repo,
teamReviews,
title,
}: Readonly<{
author: string;
Expand All @@ -99,6 +100,7 @@ const backportOnce = async ({
merged_by: string;
owner: string;
repo: string;
teamReviews: string;
title: string;
}>): Promise<number> => {
const git = async (...args: string[]) => {
Expand Down Expand Up @@ -135,7 +137,7 @@ const backportOnce = async ({
author !== merged_by && merged_by !== ""
? [author, merged_by]
: [author],
team_reviewers: ["release"],
...(teamReviews !== "" && { team_reviewers: [teamReviews] })
},
);
if (labels.length > 0) {
Expand Down Expand Up @@ -243,6 +245,7 @@ const backport = async ({
payload,
runId,
serverUrl,
teamReviews,
token,
}: {
getBody: (
Expand Down Expand Up @@ -270,6 +273,7 @@ const backport = async ({
payload: PullRequestClosedEvent | PullRequestLabeledEvent;
runId: number;
serverUrl: string;
teamReviews: string,
token: string;
}): Promise<{ [base: string]: number }> => {
const {
Expand Down Expand Up @@ -354,6 +358,7 @@ const backport = async ({
merged_by,
owner,
repo,
teamReviews,
title,
});
createdPullRequestBaseBranchToNumber[base] = backportPullRequestNumber;
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const run = async () => {

const labelPattern = getInput("label_pattern");
const labelRegExp = new RegExp(labelPattern);
const teamReviews = getInput("team_reviews");

const token = getInput("github_token", { required: true });

Expand All @@ -40,6 +41,7 @@ const run = async () => {
payload,
runId,
serverUrl,
teamReviews,
token,
});
setOutput(
Expand Down

0 comments on commit c7f54dc

Please sign in to comment.