forked from myoung34/docker-github-actions-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ephemeral-runner.sh
36 lines (29 loc) · 1.01 KB
/
ephemeral-runner.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
echo "*** Starting ephemeral runner. ***"
/actions-runner/run.sh --once
rv=$?
# See exit code constants in the runner source here:
# https://github.com/actions/runner/blob/be96323/src/Runner.Common/Constants.cs#L135
if [[ $rv == 4 ]]; then
# The runner software was updated.
echo "*** Software update detected. ***"
echo "*** Waiting for update to complete. ***"
# Hard-coded sleep. Without some delay, the update is still in progress in
# the background, leading to failures when we re-launch.
sleep 10
# Now add an adaptive delay, where we loop and check if the Runner is usable
# yet. As soon as it is, break.
for i in $(seq 10); do
if /actions-runner/bin/Runner.Listener --version &>/dev/null; then
break
fi
echo "*** Update still in progress... ***"
sleep 5
done
# Now re-launch the script.
echo "*** Re-launching runner. ***"
exec "$0"
fi
# For any other return value, let the script and the Docker container terminate.
echo "*** Exit code $rv ***"
exit $rv