-
Notifications
You must be signed in to change notification settings - Fork 2
/
status.sh
executable file
·45 lines (35 loc) · 1.19 KB
/
status.sh
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
#!/usr/bin/env bash
# Authentication
JSON="{ \"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\" }"
TOKEN=$(curl --silent --header 'Content-Type: application/json' --data "$JSON" \
https://hub.docker.com/v2/users/login | jq -r '.token')
# Execution
GAME="$1"
CMD="curl --silent --header \"Authorization: Bearer $TOKEN\" https://hub.docker.com/api/build/v1/source/\?image=lanlords/$GAME | jq -r '.objects[0].state'"
STARTED="0"
while :
do
if [ "$STARTED" == "0" ]
then
OUTPUT="$(eval $CMD)"
if [ "$OUTPUT" == "Building" ]; then
echo "[status: $OUTPUT] Docker Build has started! Waiting to finish."
STARTED="1"
else
echo "[status: $OUTPUT] Docker Build has not yet started."
fi
else
OUTPUT="$(eval $CMD)"
if [ "$OUTPUT" == "Success" ]; then
echo "[status: $OUTPUT] Docker Build has finished!"
exit 0
elif [ "$OUTPUT" == "Failed" ]; then
echo "[status: $OUTPUT] Docker build failed!"
exit 1
else
echo "[status: $OUTPUT] Docker Build is still running."
fi
fi
# wait for 5 seconds
sleep 5
done