Fix bug where team is not found with periods

Signed-off-by: Thomas Stringer <thomas@trstringer.com>
This commit is contained in:
Thomas Stringer 2022-11-11 17:18:12 -05:00
parent 753e13e935
commit 0990a51ff6
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -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