Setting exit codes for actions
You can use exit codes to set the status of an action. GitHub displays statuses to indicate passing or failing actions.
In this article
About exit codes
GitHub uses the exit code to set the action's check run status, which can besuccess
orfailure
.
Exit status | Check run status | Description |
---|---|---|
0 | success | The action completed successfully and other tasks that depend on it can begin. |
Nonzero value (any integer but 0) | failure | Any other exit code indicates the action failed. When an action fails, all concurrent actions are canceled and future actions are skipped. The check run and check suite both get afailure status. |
Setting a failure exit code in a JavaScript action
If you are creating a JavaScript action, you can use the actions toolkit@actions/core
package to log a message and set a failure exit code. For example:
try {// something}catch (error) { core.setFailed(error.message);}
For more information, seeCreating a JavaScript action.
Setting a failure exit code in a Docker container action
If you are creating a Docker container action, you can set a failure exit code in yourentrypoint.sh
script. For example:
if <condition> ; then echo "Game over!" exit 1fi
For more information, seeCreating a Docker container action.