-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpush
53 lines (42 loc) · 1.49 KB
/
push
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# If you're reading this please help; there's gotta be a better way to do this, lol.
source .env
git add .
git commit -m "updated"
output=$(git push 2>&1)
echo "$output"
if [[ "$output" == *"Everything up-to-date"* ]]; then
echo -e "\nNothing was changed! No need to run https://$DOMAIN/api/notifier/run"
exit 0
fi
echo ""
echo "**************************************************************"
echo " Waiting to run https://$DOMAIN/api/notifier/run..."
echo "**************************************************************"
sleep 10
recent_deployment_id=$(curl -s -X GET "https://api.digitalocean.com/v2/apps/$DIGITAL_OCEAN_APP_ID/deployments" \
-H "Authorization: Bearer $DIGITAL_OCEAN_API" \
-H "Content-Type: application/json" |
jq -r '.deployments[0].id')
prev_status=""
while :; do
deployment_status=$(curl -s -X GET "https://api.digitalocean.com/v2/apps/$DIGITAL_OCEAN_APP_ID/deployments/$recent_deployment_id" \
-H "Authorization: Bearer $DIGITAL_OCEAN_API" \
-H "Content-Type: application/json" |
jq -r '.deployment.phase')
if [[ "$deployment_status" == "$prev_status" ]]; then
echo -n ". "
else
echo -e "\nCurrent deployment status: $deployment_status"
prev_status=$deployment_status
fi
if [[ "$deployment_status" == "ACTIVE" ]]; then
sleep 5
curl -s https://$DOMAIN/api/notifier/run
break
fi
if [[ "$deployment_status" == "ERROR" ]]; then
exit 0
fi
sleep 2
done