1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/content/actions/creating-actions/setting-exit-codes-for-actions.md
Laura Coursen 8f964ea2cb GHEC version (#20947)
Co-authored-by: Matt Pollard <mattpollard@users.noreply.github.com>
Co-authored-by: Grace Park <gracepark@github.com>
Co-authored-by: Steve Guntrip <12534592+stevecat@users.noreply.github.com>
Co-authored-by: Robert Sese <sese@github.com>
Co-authored-by: Peter Bengtsson <peterbe@github.com>
Co-authored-by: Rachael Sewell <rachmari@github.com>
2021-10-15 15:41:33 -05:00

2.0 KiB

title, shortTitle, intro, product, redirect_from, versions, type
title shortTitle intro product redirect_from versions type
Setting exit codes for actions Setting exit codes You can use exit codes to set the status of an action. {% data variables.product.prodname_dotcom %} displays statuses to indicate passing or failing actions. {% data reusables.gated-features.actions %}
/actions/building-actions/setting-exit-codes-for-actions
fpt ghes ghae ghec
* * * *
how_to

{% data reusables.actions.enterprise-beta %} {% data reusables.actions.enterprise-github-hosted-runners %} {% data reusables.actions.ae-beta %}

About exit codes

{% data variables.product.prodname_dotcom %} uses the exit code to set the action's check run status, which can be success or failure.

Exit status Check run status Description
0 success The action completed successfully and other tasks that depends 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 a failure 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, see "Creating 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 your entrypoint.sh script. For example:

if <condition> ; then
  echo "Game over!"
  exit 1
fi

For more information, see "Creating a Docker container action."