You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow custom, non-zero exit code for core.setFailed #459
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.
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).
Reacted by Juan Julián Merelo Guervós, Pranay Sahith Bejgum and Andreas Weichselbaum
Reacted by Steve Winton, Benjamin Borowski, Joshua Grohn and Michelle Berry
Not necessarily opposed but note it's about communication to the runner.
Today 1 indicates failure, but may add other codes in the future. For example, during initial beta, 78 (iirc?) was used to indicate success, but skip downstream steps.
Reading over the documentation here I see that GitHub Actions treats an exit code of 0 as success and a non-zero exit code as failure. However just below that we see the following example of how to set a failure exit code in a JavaScript action.
Below that we see another example of how to set a failure exit code in a Docker action.
if <condition> ; then
echo "Game over!"
exit 1
fi
In these examples the Docker action provides more flexibility since we're able to exit with any code whereas a user of core.setFailed has no choice but to exit with 1.
While I can work around this in the JavaScript action, I figured it might be worth adding the ability to fail with a custom, non-zero exit code directly to the library.
Reacted by Andy Lo-A-Foe, Benjamin Borowski, Joshua Grohn, Chris Vandoodewaard, Michelle Berry and Dênio Júnior
Activity
ericsciple commentedon May 18, 2020
Not necessarily opposed but note it's about communication to the runner.
Today
1indicates failure, but may add other codes in the future. For example, during initial beta,78(iirc?) was used to indicate success, but skip downstream steps.sudomateo commentedon May 19, 2020
Thanks for the reply!
Reading over the documentation here I see that GitHub Actions treats an exit code of
0as success and a non-zero exit code as failure. However just below that we see the following example of how to set a failure exit code in a JavaScript action.Below that we see another example of how to set a failure exit code in a Docker action.
In these examples the Docker action provides more flexibility since we're able to
exitwith any code whereas a user ofcore.setFailedhas no choice but to exit with1.While I can work around this in the JavaScript action, I figured it might be worth adding the ability to fail with a custom, non-zero exit code directly to the library.
sudomateo commentedon Mar 28, 2024
Closing this issue due to inactivity. Thank you all for reading and reacting to it.