You've already forked go-semantic-release
fear(ci): add github actions
This commit is contained in:
36
internal/ci/github_actions.go
Normal file
36
internal/ci/github_actions.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package ci
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
//GithubActions struct
|
||||
type GithubActions struct{}
|
||||
|
||||
//Detect if on GithubActions
|
||||
func (t GithubActions) detect(envs map[string]string) (*ProviderConfig, error) {
|
||||
|
||||
if _, exists := envs["GITHUB_ACTION"]; !exists {
|
||||
return nil, fmt.Errorf("not running on Github Actions")
|
||||
}
|
||||
|
||||
isPR := false
|
||||
|
||||
value := envs["GITHUB_EVENT_NAME"]
|
||||
|
||||
if value == "pull_request" {
|
||||
isPR = true
|
||||
} else {
|
||||
log.Debugf("GITHUB_EVENT_NAME=%s, not running on pr", value)
|
||||
}
|
||||
|
||||
return &ProviderConfig{
|
||||
Service: "GithubActions",
|
||||
Name: "GithubActions CI",
|
||||
Commit: envs["GITHUB_SHA"],
|
||||
Branch: envs["GITHUB_REF"],
|
||||
IsPR: isPR,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user