Skip to content

Commit

Permalink
action params
Browse files Browse the repository at this point in the history
  • Loading branch information
vladopajic committed Oct 30, 2023
1 parent 0f1d4e4 commit a041fcb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
24 changes: 24 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ inputs:
required: false
default: false
type: boolean
git-token:
description: Github token.
required: false
default: "''"
type: string
git-repository:
description: Github token.
required: false
default: "''"
type: string
git-branch:
description: Github token.
required: false
default: "''"
type: string
git-file-name:
description: Github token.
required: false
default: "''"
type: string
outputs:
total-coverage:
description: Holds total coverage value.
Expand All @@ -98,6 +118,10 @@ runs:
- --cdn-file-name=${{ inputs.cdn-file-name }}
- --cdn-bucket-name=${{ inputs.cdn-bucket-name }}
- --cdn-force-path-style=${{ inputs.cdn-force-path-style }}
- --git-token=${{ inputs.git-token }}
- --git-repository=${{ inputs.git-repository }}
- --git-branch=${{ inputs.git-branch }}
- --git-file-name=${{ inputs.git-file-name }}
branding:
icon: 'code'
color: 'blue'
19 changes: 18 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ type args struct {
CDNFileName string `arg:"--cdn-file-name"`
CDNBucketName string `arg:"--cdn-bucket-name"`
CDNForcePathStyle bool `arg:"--cdn-force-path-style"`

GitToken string `arg:"--git-token"`
GitRepository string `arg:"--git-repository"`
GitBranch string `arg:"--git-branch"`
GitFileName string `arg:"--git-file-name"`
}

const (
Expand All @@ -53,14 +58,19 @@ func newArgs() args {
CDNFileName: magicString,
CDNBucketName: magicString,
CDNForcePathStyle: false,

GitToken: magicString,
GitRepository: magicString,
GitBranch: magicString,
GitFileName: magicString,
}
}

func (args) Version() string {
return "go-test-coverage " + Version
}

//nolint:cyclop // relax
//nolint:cyclop,maintidx // relax
func (a *args) overrideConfig(cfg testcoverage.Config) testcoverage.Config {
if !isMagicString(a.Profile) {
cfg.Profile = a.Profile
Expand Down Expand Up @@ -103,6 +113,13 @@ func (a *args) overrideConfig(cfg testcoverage.Config) testcoverage.Config {
}
}

if !isMagicString(a.GitToken) {
cfg.Badge.Git.Token = a.GitToken
cfg.Badge.Git.Repository = a.GitRepository
cfg.Badge.Git.Branch = a.GitBranch
cfg.Badge.Git.FileName = a.GitFileName
}

return cfg
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/testcoverage/badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func saveBadeToFile(w io.Writer, filename string, data []byte) error {
}

type Git struct {
Repository string
Token string
Repository string
Branch string
FileName string
}
Expand Down

0 comments on commit a041fcb

Please sign in to comment.