Skip to content

Commit 1ab451a

Browse files
authored
Merge pull request #32 from reload/curl-retrying
Retrying CURL, when PSH reports non-200
2 parents fade551 + 944b649 commit 1ab451a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

action.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,27 @@ runs:
113113
114114
URL=$(platform env:url -1 --pipe)
115115
116-
CURL_HTTP_STATUS=$(curl -L -s -o /dev/null -w "%{http_code}" $URL)
116+
MAX_CURL_TRIES=5
117+
CURL_SLEEP_SECONDS=5
118+
CURL_TRIES=0
119+
CURL_HTTP_STATUS=000
120+
121+
while [ "$CURL_TRIES" -lt "$MAX_CURL_TRIES" ]; do
122+
CURL_TRIES=$((CURL_TRIES+1))
123+
124+
CURL_HTTP_STATUS=$(curl -L -s -o /dev/null -w "%{http_code}" "$URL" || echo "000")
125+
126+
echo "cURL attempt $CURL_TRIES/$MAX_CURL_TRIES returned HTTP $CURL_HTTP_STATUS"
127+
128+
if [[ "$CURL_HTTP_STATUS" == "200" ]]; then
129+
break
130+
fi
131+
132+
if [ "$CURL_TRIES" -lt "$MAX_CURL_TRIES" ]; then
133+
echo "Waiting $CURL_SLEEP_SECONDS seconds before retrying CURL..."
134+
sleep "$CURL_SLEEP_SECONDS"
135+
fi
136+
done
117137
118138
if [[ "$CURL_HTTP_STATUS" != "200" ]]; then \
119139
echo "PlatformSH reports the environment is ready, but cURL could not connect to it. You may have pushed a broken build."; \

0 commit comments

Comments
 (0)