-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow custom, non-zero exit code for core.setFailed #459
Copy link
Copy link
Closed
Labels
Description
Currently, the core.setFailed function exits with an exit code of 1. However, certain applications use a non-zero exit code to indicate behavior to the user. One such example is the -detailed-exitcode argument to terraform plan (source). The ask here is to configure the core.setFailed function to accept a custom, non-zero exit code.
This will allow users of the core package to do something like this in their JavaScript actions.
const exitCode = 2
core.setFailed(`Failed with ${exitCode}`, exitCode);
I believe this change would work but I'll admit my TypeScript knowledge is novice at best.
export function setFailed(message: string | Error, code = ExitCode.Failure): void {
process.exitCode = code
error(message)
}
It might be required to add logic to ensure the passed in exit code is non-zero and non-negative since this is a setFailed function after all and we don't want someone calling core.setFailed("Failed", 0).
Reactions are currently unavailable