Skip to content

Commit 5e8e866

Browse files
committed
Make the exit code consistent across different bash environments
1 parent 158fbe8 commit 5e8e866

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ trap_with_arg() {
2020
}
2121

2222
deregister_runner() {
23+
COMMAND_EXIT_CODE=$?
2324
echo "Caught $1 - Deregistering runner"
2425
if [[ -n "${ACCESS_TOKEN}" ]]; then
2526
# If using GitHub App authentication, refresh the access token before deregistration
@@ -40,7 +41,11 @@ deregister_runner() {
4041
fi
4142
./config.sh remove --token "${RUNNER_TOKEN}"
4243
[[ -f "/actions-runner/.runner" ]] && rm -f /actions-runner/.runner
43-
exit
44+
45+
# Simply calling `exit` on different environments will either return the exit code of the passed-in $@ command, or
46+
# the exit code of the last executed command in this function. To ensure that the behavior is consistent, we always
47+
# return the exit code of the passed-in command, which is stored in COMMAND_EXIT_CODE.
48+
exit ${COMMAND_EXIT_CODE}
4449
}
4550

4651
_DEBUG_ONLY=${DEBUG_ONLY:-false}

0 commit comments

Comments
 (0)