Skip to content

Commit 6986d2c

Browse files
authored
Merge pull request #178 from tailscale/max/add-retry
action: add retry on tailscale up to make the action more reliable
2 parents 5d53611 + 029c99a commit 6986d2c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ inputs:
4848
description: 'Timeout for `tailscale up`'
4949
required: false
5050
default: '2m'
51+
retry:
52+
description: 'Number of retries for `tailscale up`'
53+
required: false
54+
default: '5'
5155
use-cache:
5256
description: 'Whether to cache the Tailscale binaries (Linux/macOS) or installer (Windows)'
5357
required: false
@@ -293,6 +297,7 @@ runs:
293297
HOSTNAME: ${{ inputs.hostname }}
294298
TAILSCALE_AUTHKEY: ${{ inputs.authkey }}
295299
TIMEOUT: ${{ inputs.timeout }}
300+
RETRY: ${{ inputs.retry }}
296301
run: |
297302
if [ -z "${HOSTNAME}" ]; then
298303
if [ "${{ runner.os }}" == "Windows" ]; then
@@ -308,4 +313,9 @@ runs:
308313
if [ "${{ runner.os }}" != "Windows" ]; then
309314
MAYBE_SUDO="sudo -E"
310315
fi
311-
timeout --verbose --kill-after=1s ${TIMEOUT} ${MAYBE_SUDO} tailscale up ${TAGS_ARG} --authkey=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes ${ADDITIONAL_ARGS}
316+
for ((i=1;i<=$RETRY;i++)); do
317+
echo "Attempt $i to bring up Tailscale..."
318+
timeout --verbose --kill-after=1s ${TIMEOUT} ${MAYBE_SUDO} tailscale up ${TAGS_ARG} --authkey=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes ${ADDITIONAL_ARGS} && break
319+
echo "Tailscale up failed. Retrying in $((i * 5)) seconds..."
320+
sleep $((i * 5))
321+
done

0 commit comments

Comments
 (0)