From ffdce936c39c1ad587f0ed17158f579b4ded067e Mon Sep 17 00:00:00 2001 From: aeddi Date: Mon, 2 Dec 2024 10:14:37 +0100 Subject: [PATCH] feat: pretty print event as json --- contribs/github-bot/internal/matrix/matrix.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contribs/github-bot/internal/matrix/matrix.go b/contribs/github-bot/internal/matrix/matrix.go index afd97fe36e2..b3e7809f1e6 100644 --- a/contribs/github-bot/internal/matrix/matrix.go +++ b/contribs/github-bot/internal/matrix/matrix.go @@ -2,6 +2,7 @@ package matrix import ( "context" + "encoding/json" "errors" "fmt" "os" @@ -21,7 +22,11 @@ func execMatrix(flags *matrixFlags) error { // If verbose is set, print the Github Actions event for debugging purpose. if *flags.verbose { - fmt.Println("Event:", actionCtx.Event) + jsonBytes, err := json.MarshalIndent(actionCtx.Event, "", " ") + if err != nil { + return fmt.Errorf("unable to marshal event to json: %w", err) + } + fmt.Println("Event:", string(jsonBytes)) } // Init Github client using only GitHub Actions context.