File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,16 @@ import (
55 "errors"
66 "fmt"
77 "io"
8+ "os"
89 "os/exec"
910 "path/filepath"
1011 "strings"
1112
1213 git "github.com/go-git/go-git/v5"
1314 "github.com/go-git/go-git/v5/plumbing"
1415 "github.com/go-git/go-git/v5/plumbing/format/diff"
16+ "github.com/go-git/go-git/v5/plumbing/transport"
17+ "github.com/go-git/go-git/v5/plumbing/transport/http"
1518 object "github.com/go-git/go-git/v5/plumbing/object"
1619
1720 "github.com/launchdarkly/ld-find-code-refs/v2/internal/ld"
@@ -199,13 +202,25 @@ func (c *Client) RemoteBranches() (branches map[string]bool, err error) {
199202 return branches , err
200203 }
201204
205+ // Configure authentication for GitHub Actions
206+ var auth transport.AuthMethod
207+ if os .Getenv ("GITHUB_ACTIONS" ) == "true" {
208+ if token := os .Getenv ("GITHUB_TOKEN" ); token != "" {
209+ log .Debug .Printf ("using GitHub token authentication for remote operations" )
210+ auth = & http.BasicAuth {
211+ Username : "x-access-token" , // GitHub requires this specific username
212+ Password : token ,
213+ }
214+ }
215+ }
216+
202217 remotes , err := repo .Remotes ()
203218 if err != nil {
204219 return branches , err
205220 }
206221
207222 for _ , r := range remotes {
208- refList , err := r .List (& git.ListOptions {})
223+ refList , err := r .List (& git.ListOptions {Auth : auth })
209224 if err != nil {
210225 return branches , err
211226 }
You can’t perform that action at this time.
0 commit comments