Skip to content

Commit

Permalink
options: If empty, set GITHUB_AUTH_TOKEN from INPUT_REPO_TOKEN
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Augustus <[email protected]>
  • Loading branch information
justaugustus committed Mar 16, 2022
1 parent 1b9fd42 commit 439b453
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ type Options struct {
InputResultsFile string `env:"INPUT_RESULTS_FILE"`
InputResultsFormat string `env:"INPUT_RESULTS_FORMAT"`
InputPublishResults string `env:"INPUT_PUBLISH_RESULTS"`

// Repo tokens
// TODO(auth): DO NOT STORE AUTH
EnvGithubAuthToken string `env:"GITHUB_AUTH_TOKEN"`
EnvInputRepoToken string `env:"INPUT_REPO_TOKEN"`
}

const (
Expand Down Expand Up @@ -132,10 +127,6 @@ func New() (*Options, error) {
return opts, errResultsPathEmpty
}

if opts.EnvGithubAuthToken == "" {
opts.EnvGithubAuthToken = opts.EnvInputRepoToken
}

if err := opts.Validate(); err != nil {
return opts, fmt.Errorf("validating scorecard-action options: %w", err)
}
Expand All @@ -158,6 +149,12 @@ func (o *Options) Initialize() error {
// o.EnableLicense = "1"
// o.EnableDangerousWorkflow = "1"

_, tokenSet := os.LookupEnv(EnvGithubAuthToken)
if !tokenSet {
inputToken := os.Getenv(EnvInputRepoToken)
os.Setenv(EnvGithubAuthToken, inputToken)
}

return o.SetRepoInfo()
}

Expand Down

0 comments on commit 439b453

Please sign in to comment.