@@ -48,65 +48,64 @@ jobs:
4848 run : vapor deploy production
4949 env :
5050 VAPOR_API_TOKEN : ${{ secrets.VAPOR_API_TOKEN }}
51+ frontend :
52+ name : Deploy Frontend
53+ runs-on : ubuntu-latest
54+ needs : backend
5155
52- frontend :
53- name : Deploy Frontend
54- runs-on : ubuntu-latest
55- needs : backend
56-
57- steps :
58- - uses : actions/checkout@v2
59-
60- - name : Trigger Deployment on DigitalOcean
61- id : trigger_deployment
62- run : |
63- RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X POST "https://api.digitalocean.com/v2/apps/${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}/deployments" \
64- -H "Authorization: Bearer ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" \
65- -H "Content-Type: application/json")
66-
67- if [ "$RESPONSE" -ne 200 ]; then
68- echo "Failed to trigger deployment. HTTP Status: $RESPONSE"
69- cat response.json
70- exit 1
71- fi
72-
73- DEPLOYMENT_ID=$(jq -r '.deployment.id' response.json)
74- if [ "$DEPLOYMENT_ID" == "null" ]; then
75- echo "Failed to extract deployment ID."
76- cat response.json
77- exit 1
78- fi
79-
80- echo "Deployment triggered successfully: $DEPLOYMENT_ID"
81- echo "deployment_id=$DEPLOYMENT_ID" >> "$GITHUB_ENV"
82-
83- - name : Poll Deployment Status
84- run : |
85- MAX_RETRIES=20 # Max polling attempts (~10 minutes)
86- SLEEP_TIME=30 # Time (in seconds) between each poll
87- COUNTER=0
56+ steps :
57+ - uses : actions/checkout@v2
8858
89- while [ $COUNTER -lt $MAX_RETRIES ]; do
90- RESPONSE=$(curl -s -X GET "https://api.digitalocean.com/v2/apps/${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}/deployments/${{ env.deployment_id }}" \
59+ - name : Trigger Deployment on DigitalOcean
60+ id : trigger_deployment
61+ run : |
62+ RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X POST "https://api.digitalocean.com/v2/apps/${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}/deployments" \
9163 -H "Authorization: Bearer ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" \
9264 -H "Content-Type: application/json")
93-
94- STATUS=$(echo "$RESPONSE" | jq -r '.deployment.phase')
95-
96- echo "Current Deployment Status: $STATUS"
97-
98- if [ "$STATUS" == "ACTIVE" ]; then
99- echo "Deployment completed successfully."
100- exit 0
101- elif [[ "$STATUS" == "FAILED" || "$STATUS" == "CANCELLED" ]]; then
102- echo "Deployment failed or was cancelled."
65+
66+ if [ "$RESPONSE" -ne 200 ]; then
67+ echo "Failed to trigger deployment. HTTP Status : $RESPONSE"
68+ cat response.json
10369 exit 1
10470 fi
71+
72+ DEPLOYMENT_ID=$(jq -r '.deployment.id' response.json)
73+ if [ "$DEPLOYMENT_ID" == "null" ]; then
74+ echo "Failed to extract deployment ID."
75+ cat response.json
76+ exit 1
77+ fi
78+
79+ echo "Deployment triggered successfully : $DEPLOYMENT_ID"
80+ echo "deployment_id=$DEPLOYMENT_ID" >> "$GITHUB_ENV"
10581
106- COUNTER=$((COUNTER + 1))
107- echo "Retrying in $SLEEP_TIME seconds... ($COUNTER/$MAX_RETRIES)"
108- sleep $SLEEP_TIME
109- done
110-
111- echo "Deployment timed out."
112- exit 1
82+ - name : Poll Deployment Status
83+ run : |
84+ MAX_RETRIES=20 # Max polling attempts (~10 minutes)
85+ SLEEP_TIME=30 # Time (in seconds) between each poll
86+ COUNTER=0
87+
88+ while [ $COUNTER -lt $MAX_RETRIES ]; do
89+ RESPONSE=$(curl -s -X GET "https://api.digitalocean.com/v2/apps/${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}/deployments/${{ env.deployment_id }}" \
90+ -H "Authorization : Bearer ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" \
91+ -H "Content-Type : application/json")
92+
93+ STATUS=$(echo "$RESPONSE" | jq -r '.deployment.phase')
94+
95+ echo "Current Deployment Status : $STATUS"
96+
97+ if [ "$STATUS" == "ACTIVE" ]; then
98+ echo "Deployment completed successfully."
99+ exit 0
100+ elif [[ "$STATUS" == "FAILED" || "$STATUS" == "CANCELLED" ]]; then
101+ echo "Deployment failed or was cancelled."
102+ exit 1
103+ fi
104+
105+ COUNTER=$((COUNTER + 1))
106+ echo "Retrying in $SLEEP_TIME seconds... ($COUNTER/$MAX_RETRIES)"
107+ sleep $SLEEP_TIME
108+ done
109+
110+ echo "Deployment timed out."
111+ exit 1
0 commit comments