You've already forked go-semantic-release
fix(ci): remove refs/heads/ from branch
This commit is contained in:
@@ -108,7 +108,7 @@ func TestCi(t *testing.T) {
|
|||||||
"GITHUB_REF": "refs/heads/feature-branch-1",
|
"GITHUB_REF": "refs/heads/feature-branch-1",
|
||||||
"GITHUB_ACTION": "action",
|
"GITHUB_ACTION": "action",
|
||||||
},
|
},
|
||||||
result: &ci.ProviderConfig{IsPR: false, PR: "", PRBranch: "", Branch: "refs/heads/feature-branch-1", Tag: "", Commit: "190bfd6aa60022afd0ef830342cfb07e33c45f37", BuildURL: "", Service: "GithubActions", Name: "GithubActions CI"},
|
result: &ci.ProviderConfig{IsPR: false, PR: "", PRBranch: "", Branch: "feature-branch-1", Tag: "", Commit: "190bfd6aa60022afd0ef830342cfb07e33c45f37", BuildURL: "", Service: "GithubActions", Name: "GithubActions CI"},
|
||||||
hasError: false,
|
hasError: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package ci
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@@ -26,11 +27,17 @@ func (t GithubActions) detect(envs map[string]string) (*ProviderConfig, error) {
|
|||||||
log.Debugf("GITHUB_EVENT_NAME=%s, not running on pr", value)
|
log.Debugf("GITHUB_EVENT_NAME=%s, not running on pr", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
branch := envs["GITHUB_REF"]
|
||||||
|
|
||||||
|
if strings.HasPrefix(envs["GITHUB_REF"], "refs/heads/") {
|
||||||
|
branch = strings.Replace(branch, "refs/heads/", "", 1)
|
||||||
|
}
|
||||||
|
|
||||||
return &ProviderConfig{
|
return &ProviderConfig{
|
||||||
Service: "GithubActions",
|
Service: "GithubActions",
|
||||||
Name: "GithubActions CI",
|
Name: "GithubActions CI",
|
||||||
Commit: envs["GITHUB_SHA"],
|
Commit: envs["GITHUB_SHA"],
|
||||||
Branch: envs["GITHUB_REF"],
|
Branch: branch,
|
||||||
IsPR: isPR,
|
IsPR: isPR,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,12 +179,12 @@ func (s *SemanticRelease) WriteChangeLog(changelogContent, file string) error {
|
|||||||
func (s *SemanticRelease) Release(provider *ci.ProviderConfig, force bool) error {
|
func (s *SemanticRelease) Release(provider *ci.ProviderConfig, force bool) error {
|
||||||
|
|
||||||
if provider.IsPR {
|
if provider.IsPR {
|
||||||
log.Debugf("Will not perform a new release. This is a pull request")
|
log.Infof("Will not perform a new release. This is a pull request")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := s.config.Branch[provider.Branch]; !ok {
|
if _, ok := s.config.Branch[provider.Branch]; !ok {
|
||||||
log.Debugf("Will not perform a new release. Current %s branch is not configured in release config", provider.Branch)
|
log.Infof("Will not perform a new release. Current %s branch is not configured in release config", provider.Branch)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user