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).
Currently, the
core.setFailedfunction exits with an exit code of1. However, certain applications use a non-zero exit code to indicate behavior to the user. One such example is the-detailed-exitcodeargument toterraform plan(source). The ask here is to configure thecore.setFailedfunction to accept a custom, non-zero exit code.This will allow users of the
corepackage to do something like this in their JavaScript actions.I believe this change would work but I'll admit my TypeScript knowledge is novice at best.
It might be required to add logic to ensure the passed in exit code is non-zero and non-negative since this is a
setFailedfunction after all and we don't want someone callingcore.setFailed("Failed", 0).