mirror of
https://github.com/zerotier/github-action.git
synced 2026-05-22 16:27:40 -07:00
Avoid infinite loop while joining
Probably resolve https://github.com/zerotier/github-action/issues/9
This commit is contained in:
+21
-2
@@ -44,8 +44,27 @@ runs:
|
||||
esac
|
||||
|
||||
echo "⏁ Authorizing Runner to ZeroTier network"
|
||||
while ! curl -s -X POST -H "Authorization: token ${{ inputs.auth_token }}" -H "Content-Type: application/json" -d '{"name":"Zerotier GitHub Member '"${GITHUB_SHA::7}"'", "description": "Member created by '"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"'", "config":{"authorized":true}}' "${{ inputs.api_url }}/network/${{ inputs.network_id }}/member/${member_id}" | grep '"authorized":true' ; do sleep 2 ; done
|
||||
|
||||
MAX_RETRIES=10
|
||||
RETRY_COUNT=0
|
||||
|
||||
while ! curl -s -X POST \
|
||||
-H "Authorization: token ${{ inputs.auth_token }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"Zerotier GitHub Member '"${GITHUB_SHA::7}"'", "description": "Member created by '"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"'", "config":{"authorized":true}}' \
|
||||
"${{ inputs.api_url }}/network/${{ inputs.network_id }}/member/${member_id}" | grep '"authorized":true';
|
||||
do
|
||||
RETRY_COUNT=$((RETRY_COUNT+1))
|
||||
|
||||
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
|
||||
echo "Reached maximum number of retries ($MAX_RETRIES). Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Authorization failed. Retrying in 2 seconds... (Attempt $RETRY_COUNT of $MAX_RETRIES)"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "Member authorized successfully."
|
||||
echo "⏁ Joining ZeroTier Network ID: ${{ inputs.network_id }}"
|
||||
case $(uname -s) in
|
||||
MINGW64_NT?*)
|
||||
|
||||
Reference in New Issue
Block a user