forked from SeaDve/Mousai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flathub_wait_for_build.sh
51 lines (42 loc) · 1.35 KB
/
flathub_wait_for_build.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
46
47
48
49
50
51
#!/bin/bash
# Forked from https://github.com/geigi/cozy/blob/master/.ci/flathub_wait_for_build.sh
URL_RUNNING_BUILDS="https://flathub.org/builds/api/v2/builders/32/builds?complete=false&flathub_name__eq=io.github.seadve.Mousai&order=-number&property=owners&property=workername"
URL_LAST_BUILD="https://flathub.org/builds/api/v2/builders/32/builds?flathub_name__eq=io.github.seadve.Mousai&flathub_repo_status__gt=1&limit=1&order=-number&property=owners&property=workername"
function wait_for_build_triggered {
for i in {0..30}
do
sleep 1
builds_in_progress=$(curl $URL_RUNNING_BUILDS | json meta.total)
if (( builds_in_progress > 0 )); then
echo "$builds_in_progress build(s) in progress."
return 0
fi
done
echo "No build in progress."
return 1
}
wait_for_build_triggered
build_triggered=$?
if (( $build_triggered > 0 )); then
exit 1
fi
builds_in_progress=$(curl $URL_RUNNING_BUILDS | json meta.total)
counter=0
while [[ $builds_in_progress != [0] ]]
do
echo "$builds_in_progress build(s) in progress."
sleep 5
builds_in_progress=$(curl $URL_RUNNING_BUILDS | json meta.total)
counter=$((counter+5))
if (( counter > 1800 )); then
echo "Build longer than 30min, failing!"
exit 1
fi
done
result=$(curl $URL_LAST_BUILD | json builds[0].results)
if (( builds_in_progress > 0 )); then
echo "Build failed."
exit 1
fi
echo "Build succeeded."
exit 0