From 45315488a210a16aafdcb58457fe0895c8444903 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 7 Dec 2022 13:11:29 +0100 Subject: [PATCH] Fix deprecated usage of ::set-output --- main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 54aaed7..0d7715c 100644 --- a/main.go +++ b/main.go @@ -76,9 +76,21 @@ func main() { fmt.Print(string(output)) if os.Getenv("GITHUB_WORKSPACE") != "" { + gOutFile := os.Getenv("GITHUB_OUTPUT") + + f, err := os.OpenFile(gOutFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Fprintf(os.Stderr, fmt.Sprintf("unable to open github output: %s\n", err)) + os.Exit(127) + } + defer f.Close() + // inside a Github action, export vulns if output, err := security.Format(vulns, "raw_json"); err == nil { - fmt.Printf("::set-output name=vulns::%s", output) + if _, err = f.WriteString("vulns=" + string(output) + "\n"); err != nil { + fmt.Fprintf(os.Stderr, fmt.Sprintf("unable to write into github output: %s\n", err)) + os.Exit(127) + } } }