Skip to content

Commit

Permalink
use token if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
rajatjindal committed Feb 3, 2020
1 parent a82ada7 commit 4732921
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github/v29 v29.0.2 h1:opYN6Wc7DOz7Ku3Oh4l7prmkOMwEcQxpFtxdU8N8Pts=
github.com/google/go-github/v29 v29.0.2/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
Expand Down
12 changes: 11 additions & 1 deletion pkg/source/actions/action_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ import (
"github.com/rajatjindal/krew-release-bot/pkg/cicd"
"github.com/rajatjindal/krew-release-bot/pkg/source"
"github.com/sirupsen/logrus"
"golang.org/x/oauth2"
)

func getHTTPClient() *http.Client {
if os.Getenv("GITHUB_TOKEN") != "" {
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")})
return oauth2.NewClient(context.TODO(), ts)
}

return nil
}

//RunAction runs the github action
func RunAction() error {
client := github.NewClient(nil)
client := github.NewClient(getHTTPClient())
provider := cicd.GetProvider()

if provider == nil {
Expand Down

0 comments on commit 4732921

Please sign in to comment.