Skip to content

Commit 10b21df

Browse files
authored
Merge pull request #141 from joeyparrish/deregistration
Fix runner deregistration with ACCESS_TOKEN
2 parents 4df911f + e386012 commit 10b21df

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

entrypoint.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
export RUNNER_ALLOW_RUNASROOT=1
44
export PATH=$PATH:/actions-runner
55

6+
# Un-export these, so that they must be passed explicitly to the environment of
7+
# any command that needs them. This may help prevent leaks.
8+
export -n ACCESS_TOKEN
9+
export -n RUNNER_TOKEN
10+
611
deregister_runner() {
712
echo "Caught SIGTERM. Deregistering runner"
8-
_TOKEN=$(bash /token.sh)
9-
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
13+
if [[ -n "${ACCESS_TOKEN}" ]]; then
14+
_TOKEN=$(ACCESS_TOKEN="${ACCESS_TOKEN}" bash /token.sh)
15+
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
16+
fi
1017
./config.sh remove --token "${RUNNER_TOKEN}"
1118
exit
1219
}
@@ -53,8 +60,8 @@ esac
5360

5461
configure_runner() {
5562
if [[ -n "${ACCESS_TOKEN}" ]]; then
56-
echo "Obtaining the token of the runner"
57-
_TOKEN=$(bash /token.sh)
63+
echo "Obtaining the token of the runnet"
64+
_TOKEN=$(ACCESS_TOKEN="${ACCESS_TOKEN}" bash /token.sh)
5865
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
5966
fi
6067

@@ -101,8 +108,5 @@ if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
101108
trap deregister_runner SIGINT SIGQUIT SIGTERM
102109
fi
103110

104-
unset ACCESS_TOKEN
105-
unset RUNNER_TOKEN
106-
107111
# Container's command (CMD) execution
108112
"$@"

0 commit comments

Comments
 (0)