From 8362431a1e41c837fef7a113c549d6a255b26509 Mon Sep 17 00:00:00 2001 From: Jeongwon Song <46633758+jsong336@users.noreply.github.com> Date: Mon, 19 Feb 2024 23:55:27 -0500 Subject: [PATCH] Fix: Check for git authentication when GITHUB_TOKEN exists (#463) Signed-off-by: Jeongwon Song --- flytectl/pkg/github/githubutil.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flytectl/pkg/github/githubutil.go b/flytectl/pkg/github/githubutil.go index 2d72b67af7..680085370b 100644 --- a/flytectl/pkg/github/githubutil.go +++ b/flytectl/pkg/github/githubutil.go @@ -231,7 +231,12 @@ func GetGHRepoService() GHRepoService { gh = github.NewClient(oauth2.NewClient(context.Background(), oauth2.StaticTokenSource( &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, ))) - } else { + if _, err := ListReleases(flyte, gh.Repositories); err != nil { + logger.Warnf(context.Background(), "Found GITHUB_TOKEN but failed to fetch releases. Using empty http.Client: %s.", err) + gh = nil + } + } + if gh == nil { gh = github.NewClient(&http.Client{}) } return gh.Repositories