From 0990a51ff6087e012a55cf3c689eb9adcc7e8852 Mon Sep 17 00:00:00 2001 From: Thomas Stringer Date: Fri, 11 Nov 2022 17:18:12 -0500 Subject: [PATCH 1/4] Fix bug where team is not found with periods Signed-off-by: Thomas Stringer --- action.yaml | 2 +- approvers.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 9fd7fdb..0453537 100644 --- a/action.yaml +++ b/action.yaml @@ -21,4 +21,4 @@ inputs: default: false runs: using: docker - image: docker://ghcr.io/trstringer/manual-approval:1.7.0 + image: docker://ghcr.io/trstringer/manual-approval-test:1.7.1-rc.1 diff --git a/approvers.go b/approvers.go index d7aae15..b12de6d 100644 --- a/approvers.go +++ b/approvers.go @@ -58,7 +58,13 @@ func retrieveApprovers(client *github.Client, repoOwner string) ([]string, error func expandGroupFromUser(client *github.Client, org, userOrTeam string, workflowInitiator string, shouldExcludeWorkflowInitiator bool) []string { fmt.Printf("Attempting to expand user %s/%s as a group (may not succeed)\n", org, userOrTeam) - users, _, err := client.Teams.ListTeamMembersBySlug(context.Background(), org, userOrTeam, &github.TeamListTeamMembersOptions{}) + + // GitHub replaces periods in the team name with hyphens. If a period is + // passed to the request it would result in a 404. So we need to replace + // and occurrences with a hyphen. + formattedUserOrteam := strings.ReplaceAll(userOrTeam, ".", "-") + + users, _, err := client.Teams.ListTeamMembersBySlug(context.Background(), org, formattedUserOrteam, &github.TeamListTeamMembersOptions{}) if err != nil { fmt.Printf("%v\n", err) return nil From 1426c1b34db3cd08b09c51608f1eb1323990169c Mon Sep 17 00:00:00 2001 From: Thomas Stringer Date: Fri, 11 Nov 2022 17:49:53 -0500 Subject: [PATCH 2/4] Revert image change for testing Signed-off-by: Thomas Stringer --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 0453537..ebb981e 100644 --- a/action.yaml +++ b/action.yaml @@ -21,4 +21,4 @@ inputs: default: false runs: using: docker - image: docker://ghcr.io/trstringer/manual-approval-test:1.7.1-rc.1 + image: docker://ghcr.io/trstringer/manual-approval-test:1.7.0 From 9348590e8df3db605f4fef18bfb253217cadd516 Mon Sep 17 00:00:00 2001 From: Thomas Stringer Date: Fri, 11 Nov 2022 17:50:53 -0500 Subject: [PATCH 3/4] Change image repo back from testing Signed-off-by: Thomas Stringer --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index ebb981e..9fd7fdb 100644 --- a/action.yaml +++ b/action.yaml @@ -21,4 +21,4 @@ inputs: default: false runs: using: docker - image: docker://ghcr.io/trstringer/manual-approval-test:1.7.0 + image: docker://ghcr.io/trstringer/manual-approval:1.7.0 From 30875d0b33a93d38b9d568f171a8f26d717fbe96 Mon Sep 17 00:00:00 2001 From: Thomas Stringer Date: Fri, 11 Nov 2022 17:52:24 -0500 Subject: [PATCH 4/4] Change variable name Signed-off-by: Thomas Stringer --- approvers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/approvers.go b/approvers.go index b12de6d..c3f129f 100644 --- a/approvers.go +++ b/approvers.go @@ -62,9 +62,9 @@ func expandGroupFromUser(client *github.Client, org, userOrTeam string, workflow // GitHub replaces periods in the team name with hyphens. If a period is // passed to the request it would result in a 404. So we need to replace // and occurrences with a hyphen. - formattedUserOrteam := strings.ReplaceAll(userOrTeam, ".", "-") + formattedUserOrTeam := strings.ReplaceAll(userOrTeam, ".", "-") - users, _, err := client.Teams.ListTeamMembersBySlug(context.Background(), org, formattedUserOrteam, &github.TeamListTeamMembersOptions{}) + users, _, err := client.Teams.ListTeamMembersBySlug(context.Background(), org, formattedUserOrTeam, &github.TeamListTeamMembersOptions{}) if err != nil { fmt.Printf("%v\n", err) return nil