From 9769c4c7ea735a5d4cc2d04665d745be6fa9e0c9 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Fri, 23 Aug 2024 16:02:51 +0300 Subject: [PATCH] Add timeout --- .github/workflows/gradle.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 88f5d064..99d5e058 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -91,6 +91,10 @@ jobs: - name: Check runner status and wait if offline id: check_status run: | + MAX_WAIT=300 + WAIT_INTERVAL=10 + ELAPSED_TIME=0 + RUNNER_STATUS=$(curl -s -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ @@ -98,9 +102,10 @@ jobs: https://api.github.com/repos/$REPO/actions/runners | jq -r '.runners[0].status') echo "Initial Runner status is: $RUNNER_STATUS" - while [[ "$RUNNER_STATUS" != "online" ]]; do - echo "Runner is $RUNNER_STATUS. Waiting for 10 seconds..." - sleep 10 + while [[ "$RUNNER_STATUS" != "online" && "$ELAPSED_TIME" -lt "$MAX_WAIT" ]]; do + echo "Runner is $RUNNER_STATUS. Waiting for $WAIT_INTERVAL seconds..." + sleep $WAIT_INTERVAL + ELAPSED_TIME=$((ELAPSED_TIME + WAIT_INTERVAL)) RUNNER_STATUS=$(curl -s -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \