From df98fa28b1a53114624ff70a4273b893645eda7e Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Sun, 30 Oct 2022 22:33:56 -0700 Subject: [PATCH] Add retries to _build Deployment Verification job (#60) --- .github/workflows/_deploy.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/_deploy.yml b/.github/workflows/_deploy.yml index 0b01e6a..2d76362 100644 --- a/.github/workflows/_deploy.yml +++ b/.github/workflows/_deploy.yml @@ -113,15 +113,27 @@ jobs: if: steps.get-route.outputs.route &&( inputs.penetration_test != 'true' ) run: | # Curl URL and verify http code 200 + + # Vars URL="${{ steps.get-route.outputs.route }}" - if [ $(curl -ILso /dev/null -w "%{http_code}" "${URL}") -ne 200 ] - then - HTTP_CODE=$(curl -ILso /dev/null -w "%{http_code}" "${URL}") - echo -e "Failure! \n\tStatus = ${HTTP_CODE} \n\tURL: ${URL}\n" - exit 1 - fi - echo -e "Deployment successful!" - [ -z "${URL}"] || echo "URL: ${URL}" + RETRIES=2 + + # Info + echo -e "\n${URL}\n" + + # Curl and verify + while [ ${RETRIES} -gt 0 ]; do + HTTP_CODE=$(curl -ILso /dev/null -w "%{http_code}" "${URL}") + if [ "${HTTP_CODE}" -eq 200 ]; then + echo -e "Deployment successful!" + exit + fi + echo -e "\nHTTP_CODE:${HTTP_CODE}, RETRIES:${RETRIES}" + RETRIES=$((RETRIES-1)) + sleep 10 + done + echo -e "\nDeployment verification failed" + exit 1 - name: Penetration Test if: steps.get-route.outputs.route &&( inputs.penetration_test == 'true' )