From e31e1f9ba080bf0486dcc04940671a5ae439f75a Mon Sep 17 00:00:00 2001 From: Thibault Jamet Date: Mon, 2 Nov 2020 21:25:20 +0100 Subject: [PATCH] Add SetFailedf and IsDebug helpers SetFailedf prevents from having to use Sprintf in caller methods --- core/core.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/core.go b/core/core.go index 511e17e..b7d79e0 100644 --- a/core/core.go +++ b/core/core.go @@ -63,6 +63,11 @@ func SetOutput(name, value string) { IssueCommand("set-output", map[string]string{"name": name}, value) } +// SetFailedf sets the action status to failed and sets an error message +func SetFailedf(format string, args ...interface{}) { + SetFailed(fmt.Sprintf(format, args...)) +} + // SetFailed sets the action status to failed and sets an error message func SetFailed(message string) { statusAccess.Lock() @@ -139,3 +144,8 @@ func SaveState(name, value string) { func GetState(name string) string { return os.Getenv("STATE_" + name) } + +// IsDebug returns whether the github actions is currently under debug +func IsDebug() bool { + return os.Getenv("RUNNER_DEBUG") == "1" +}