Skip to content

Commit bd796fc

Browse files
authored
Merge pull request #49 from vbatts/github-actions
main: add support for github actions
2 parents 5fd8690 + 5939206 commit bd796fc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ jobs:
3434
go vet -x ./...
3535
go build -v .
3636
go test -v ./...
37+
./git-validation -run DCO,short-subject,dangling-whitespace -v
3738
./git-validation -run DCO,short-subject,dangling-whitespace -v -range ${GITHUB_SHA}..HEAD

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var (
2222
flDebug = flag.Bool("D", false, "debug output")
2323
flQuiet = flag.Bool("q", false, "less output")
2424
flDir = flag.String("d", ".", "git directory to validate from")
25+
flNoGithub = flag.Bool("no-github", false, "disables Github Actions environment checks (when env GITHUB_ACTIONS=true is set)")
2526
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
2627
flTravisPROnly = flag.Bool("travis-pr-only", true, "when on travis, only run validations if the CI-Build is checking pull-request build")
2728
)
@@ -73,6 +74,10 @@ func main() {
7374
commitRange = os.Getenv("TRAVIS_COMMIT")
7475
}
7576
}
77+
// https://docs.github.com/en/actions/reference/environment-variables
78+
if strings.ToLower(os.Getenv("GITHUB_ACTIONS")) == "true" && !*flNoGithub {
79+
commitRange = fmt.Sprintf("%s..%s", os.Getenv("GITHUB_SHA"), "HEAD")
80+
}
7681
}
7782

7883
runner, err := validate.NewRunner(*flDir, rules, commitRange, *flVerbose)

0 commit comments

Comments
 (0)