From cf47e5b3a73b7c8ebfa3e3ef907a78aa86597200 Mon Sep 17 00:00:00 2001 From: Marcell Dechant Date: Tue, 21 May 2024 21:11:32 +0200 Subject: [PATCH] Add wait for deployment to finish --- .github/workflows/deployment.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 35e1c81..f1cbf4c 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -82,7 +82,7 @@ jobs: needs: push-to-docker-hub environment: name: Capstone Project # Capstone Project name - url: https://neuefische.de/ # Link to deployment + url: https://fullstack-v15z.onrender.com # Link to deployment steps: - name: Trigger Render.com Deployment id: trigger-deploy @@ -95,6 +95,20 @@ jobs: id=$(echo "$response" | jq -r '.id') echo "deploy_id=$id" >> $GITHUB_ENV - - name: Use Deployment ID + - name: Wait for Deployment to finish run: | - echo "Deployment ID: ${{ env.deploy_id }}" \ No newline at end of file + curl=$(curl --request GET \ + --url https://api.render.com/v1/services/${{ secrets.RENDER_SERVICE_ID }}/deploys/${{ env.deploy_id }} \ + --header 'accept: application/json' \ + --header 'authorization: Bearer ${{ secrets.RENDER_API_KEY }}') + status=$(echo "$curl" | jq -r '.status') + maxTries=10 + while [ "$status" != "live" ] && [ $maxTries -gt 0 ]; do + maxTries=$((maxTries - 1)) + sleep 10 + curl=$(curl --request GET \ + --url https://api.render.com/v1/services/${{ secrets.RENDER_SERVICE_ID }}/deploys/${{ env.deploy_id }} \ + --header 'accept: application/json' \ + --header 'authorization: Bearer ${{ secrets.RENDER_API_KEY }}') + status=$(echo "$curl" | jq -r '.status') + done \ No newline at end of file