From f88893748a54c97587dbf757dd54a06b216a459f Mon Sep 17 00:00:00 2001 From: jake Date: Tue, 11 Nov 2025 18:04:21 -0500 Subject: [PATCH] adding fails and fail skips --- action.yaml | 8 +++++--- main.go | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index 8f739da..f86b182 100644 --- a/action.yaml +++ b/action.yaml @@ -9,12 +9,14 @@ inputs: description: "what level of issues to show (all|fatal)" required: false default: "all" -outputs: - report: - description: "results of the scan" + fail: + description: "determines whether or not the workflow fails upon finding fatal issues (yes(default)|no)" + required: false + default: "yes" runs: using: docker image: Dockerfile env: COMPOSE_FILE_PATH: ${{ inputs.path }} LOG_LEVEL: ${{ inputs.show }} + FAIL_ON_FATAL: ${{ inputs.fail }} diff --git a/main.go b/main.go index 354554a..ef923a7 100644 --- a/main.go +++ b/main.go @@ -98,11 +98,15 @@ func main() { //this is better printing, it should probably group up the port issues in a better printing. Not sure how lvl := os.Getenv("LOG_LEVEL") + fatalCount := 0 for _, p := range issues { fmt.Println() fmt.Println("----------------------------------------------------------------------------") fmt.Println(p.Name) for _, x := range p.Issues { + if x.Level == issue.FATAL { + fatalCount++ + } if lvl == "all" { fmt.Printf("\tsafe: %t\n\tlevel: %s\n\tMessages:\n\t\t%s\n\n", x.Safe, x.Level, strings.Join(x.Messages, "\n\t\t")) } else if lvl == "fatal" { @@ -112,6 +116,10 @@ func main() { } } } + + if strings.EqualFold(os.Getenv("FAIL_ON_FATAL"), "yes") { + os.Exit(fatalCount) + } } // ensure cpus and mem_limit are set on the service