Skip to content

Commit

Permalink
Write results also to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Nov 24, 2023
1 parent 343d717 commit 7e5bd36
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"io"
"os"

"github.com/buildkite/shellwords"
Expand All @@ -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)
Expand All @@ -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())
Expand Down

0 comments on commit 7e5bd36

Please sign in to comment.