fear(ci): add github actions

This commit is contained in:
Nightapes
2019-08-21 21:39:05 +02:00
parent 7857b5f6f3
commit 89f4842a2b
4 changed files with 62 additions and 1 deletions

View 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
}