From 7f39b70e2c26fbababa58535c821caa179de9e37 Mon Sep 17 00:00:00 2001 From: Istvan Hegedus Date: Tue, 9 Sep 2025 21:48:51 -0600 Subject: [PATCH 1/2] feat: add auth header for gha run --- internal/git/git.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/git/git.go b/internal/git/git.go index db31617a5..41be1cd1b 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "os" "os/exec" "path/filepath" "strings" @@ -12,6 +13,8 @@ import ( git "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/format/diff" + "github.com/go-git/go-git/v5/plumbing/transport" + "github.com/go-git/go-git/v5/plumbing/transport/http" object "github.com/go-git/go-git/v5/plumbing/object" "github.com/launchdarkly/ld-find-code-refs/v2/internal/ld" @@ -199,13 +202,25 @@ func (c *Client) RemoteBranches() (branches map[string]bool, err error) { return branches, err } + // Configure authentication for GitHub Actions + var auth transport.AuthMethod + if os.Getenv("GITHUB_ACTIONS") == "true" { + if token := os.Getenv("GITHUB_TOKEN"); token != "" { + log.Debug.Printf("using GitHub token authentication for remote operations") + auth = &http.BasicAuth{ + Username: "x-access-token", // GitHub requires this specific username + Password: token, + } + } + } + remotes, err := repo.Remotes() if err != nil { return branches, err } for _, r := range remotes { - refList, err := r.List(&git.ListOptions{}) + refList, err := r.List(&git.ListOptions{Auth: auth}) if err != nil { return branches, err } From c7768e5c657ac64d725506a072ca90113098a2d3 Mon Sep 17 00:00:00 2001 From: Istvan Hegedus Date: Tue, 23 Dec 2025 07:46:47 -0700 Subject: [PATCH 2/2] fix: run gofmt on this file --- internal/git/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/git/git.go b/internal/git/git.go index 41be1cd1b..9594f85fc 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -13,9 +13,9 @@ import ( git "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/format/diff" + object "github.com/go-git/go-git/v5/plumbing/object" "github.com/go-git/go-git/v5/plumbing/transport" "github.com/go-git/go-git/v5/plumbing/transport/http" - object "github.com/go-git/go-git/v5/plumbing/object" "github.com/launchdarkly/ld-find-code-refs/v2/internal/ld" "github.com/launchdarkly/ld-find-code-refs/v2/options"