Skip to content

Commit 320b9bf

Browse files
committed
Update YAML
1 parent df453b5 commit 320b9bf

File tree

1 file changed

+58
-10
lines changed

1 file changed

+58
-10
lines changed

.github/workflows/deploy-production.yml

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,64 @@ jobs:
4949
env:
5050
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
5151

52-
frontend:
53-
name: Deploy Frontend
54-
runs-on: ubuntu-latest
55-
needs: backend
52+
frontend:
53+
name: Deploy Frontend
54+
runs-on: ubuntu-latest
55+
needs: backend
5656

57-
steps:
58-
- uses: actions/checkout@v2
57+
steps:
58+
- uses: actions/checkout@v2
5959

60-
- name: Deploy to DigitalOcean App Platform
61-
run: |
62-
curl -X POST "https://api.digitalocean.com/v2/apps/${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}/deployments" \
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
88+
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 }}" \
6391
-H "Authorization: Bearer ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" \
64-
-H "Content-Type: application/json"
92+
-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."
103+
exit 1
104+
fi
105+
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

0 commit comments

Comments
 (0)