mirror of
https://github.com/vbatts/git-validation.git
synced 2024-11-25 09:35:40 +00:00
Merge pull request #49 from vbatts/github-actions
main: add support for github actions
This commit is contained in:
commit
bd796fc6ad
2 changed files with 6 additions and 0 deletions
1
.github/workflows/go.yml
vendored
1
.github/workflows/go.yml
vendored
|
@ -34,4 +34,5 @@ jobs:
|
|||
go vet -x ./...
|
||||
go build -v .
|
||||
go test -v ./...
|
||||
./git-validation -run DCO,short-subject,dangling-whitespace -v
|
||||
./git-validation -run DCO,short-subject,dangling-whitespace -v -range ${GITHUB_SHA}..HEAD
|
||||
|
|
5
main.go
5
main.go
|
@ -22,6 +22,7 @@ var (
|
|||
flDebug = flag.Bool("D", false, "debug output")
|
||||
flQuiet = flag.Bool("q", false, "less output")
|
||||
flDir = flag.String("d", ".", "git directory to validate from")
|
||||
flNoGithub = flag.Bool("no-github", false, "disables Github Actions environment checks (when env GITHUB_ACTIONS=true is set)")
|
||||
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
|
||||
flTravisPROnly = flag.Bool("travis-pr-only", true, "when on travis, only run validations if the CI-Build is checking pull-request build")
|
||||
)
|
||||
|
@ -73,6 +74,10 @@ func main() {
|
|||
commitRange = os.Getenv("TRAVIS_COMMIT")
|
||||
}
|
||||
}
|
||||
// https://docs.github.com/en/actions/reference/environment-variables
|
||||
if strings.ToLower(os.Getenv("GITHUB_ACTIONS")) == "true" && !*flNoGithub {
|
||||
commitRange = fmt.Sprintf("%s..%s", os.Getenv("GITHUB_SHA"), "HEAD")
|
||||
}
|
||||
}
|
||||
|
||||
runner, err := validate.NewRunner(*flDir, rules, commitRange, *flVerbose)
|
||||
|
|
Loading…
Reference in a new issue