Skip to content

Commit

Permalink
Merge pull request #167 from replicatedhq/gha-branch
Browse files Browse the repository at this point in the history
better GHA branch detection
  • Loading branch information
dexhorthy authored Dec 29, 2020
2 parents 4056cff + 5bd30db commit 6d03a6c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cli/cmd/release_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (r *runners) InitReleaseCreate(parent *cobra.Command) error {
func (r *runners) gitSHABranch() (sha string, branch string, dirty bool, err error) {
path := "."
rev := "HEAD"
repository, err := git.PlainOpen(path)
repository, err := git.PlainOpenWithOptions(path, &git.PlainOpenOptions{DetectDotGit: true})
if err != nil {
return "", "", false, errors.Wrapf(err, "open %q", path)
}
Expand All @@ -85,7 +85,15 @@ func (r *runners) gitSHABranch() (sha string, branch string, dirty bool, err err
return "", "", false, errors.Wrap(err, "get git status")
}

return h.String()[0:7], head.Name().Short(), !status.IsClean(), nil
branchName := head.Name().Short()

// for GH Actions, prefer env branch
envBranch := os.Getenv("GITHUB_BRANCH")
if envBranch != "" {
branchName = envBranch
}

return h.String()[0:7], branchName, !status.IsClean(), nil
}

func (r *runners) setKOTSDefaultReleaseParams() error {
Expand Down

0 comments on commit 6d03a6c

Please sign in to comment.