From 7e5bd36ac807efa9c996cd0b6089f7e2b5bf0198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20Kivim=C3=A4ki?= Date: Fri, 24 Nov 2023 14:10:24 +0200 Subject: [PATCH] Write results also to stdout --- cmd/action/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/action/main.go b/cmd/action/main.go index 47c0fd49..0a2fce25 100644 --- a/cmd/action/main.go +++ b/cmd/action/main.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "io" "os" "github.com/buildkite/shellwords" @@ -25,6 +26,9 @@ func main() { output, err := os.OpenFile(os.Getenv("GITHUB_OUTPUT"), os.O_APPEND|os.O_WRONLY, 0644) checkErr(err) + // Write contents to the output file and to stdout + out := io.MultiWriter(os.Stdout, output) + // Since arguments are passed as a single string, we need to split them args, err := shellwords.Split(os.Args[1]) checkErr(err) @@ -33,7 +37,7 @@ func main() { fmt.Fprintf(output, "%s<<%s\n", OutputResult, delimiter) cmd := cli.NewRootCmd("") - cmd.SetOut(output) + cmd.SetOut(out) cmd.SetArgs(args) err = cmd.ExecuteContext(context.Background())