From 8c1a8b210ee10e2a63c4145998761348eaee3fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20Kivim=C3=A4ki?= Date: Thu, 9 Nov 2023 14:55:50 +0200 Subject: [PATCH] Make sure that the buffer is written to the file --- cmd/action/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/action/main.go b/cmd/action/main.go index 41bc9e14..4bce5590 100644 --- a/cmd/action/main.go +++ b/cmd/action/main.go @@ -26,7 +26,6 @@ func main() { output, err := os.OpenFile(filename, os.O_APPEND, 0644) checkErr(err) - defer output.Close() cmd := cli.NewRootCmd(version) err = cmd.ExecuteContext(context.Background()) @@ -41,6 +40,10 @@ func main() { } fmt.Fprintf(output, "exit-code=%d\n", exitCode) + // Write buffer to the file + output.Sync() + output.Close() + // Map all non error exit codes to 0 so that Github Actions job does not fail if exitCode != cli.ExitCodeError { os.Exit(cli.ExitCodeOK)