diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index ee785f2..9542f9a 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -105,9 +105,22 @@ jobs: - name: Check deploy server URL uses: jtalk/url-health-check-action@v3 with: - url: https://${{ secrets.LIVE_SERVER_IP }}:${{env.STOPPED_PORT}}/env - max-attempts: 5 - retry-delay: 10s + username: ubuntu + host: ${{ secrets.LIVE_SERVER_IP }} + key: ${{ secrets.EC2_SSH_KEY }} + script: | + for i in {1..5}; do + STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:${{env.STOPPED_PORT}}/env) + if [ "$STATUS" = "200" ]; then + echo "Health check passed" + exit 0 + else + echo "Waiting for app to be ready... ($i/5)" + sleep 10 + fi + done + echo "Health check failed" + exit 1 - name: Change nginx upstream uses: appleboy/ssh-action@master