@@ -8,23 +8,34 @@ if [ "$#" -lt 2 ]; then
8
8
fi
9
9
10
10
ENDPOINT=" $1 "
11
- TARGET_HASH=" $2 "
12
- # If no third argument is provided, no delay is applied
13
- if [ " $# " -ge 3 ]; then
14
- MAX_DELAY=" $3 "
11
+ TARGET_STRING=" $2 "
12
+
13
+ # If no third argument is provided, no maximum delay is applied
14
+ MAX_DELAY=" ${3:- } "
15
+
16
+ # If it starts with `v`, treat it as a tag
17
+ if [[ " $TARGET_STRING " =~ ^v[0-9]+ ]]; then
18
+ echo " Interpreted '$TARGET_STRING ' as a Git tag. Resolving to short SHA..."
19
+ SHORT_SHA=" $( git rev-parse --short " refs/tags/$TARGET_STRING " ) " || {
20
+ echo " ERROR: Tag $TARGET_STRING is not present"
21
+ exit 1
22
+ }
23
+ else
24
+ echo " Interpreted '$TARGET_STRING ' as a short SHA (or unknown tag). Using it as-is..."
25
+ SHORT_SHA=" $TARGET_STRING "
15
26
fi
16
27
17
28
# Initial delay in seconds (60, then doubles each time)
18
29
DELAY=60
19
30
20
- echo " Watching $ENDPOINT for Build: staging@ $TARGET_HASH ..."
31
+ echo " Watching $ENDPOINT for Build: .*@ ${SHORT_SHA} ..."
21
32
while true
22
33
do
23
34
PAGE_CONTENT=" $( curl -s " $ENDPOINT " ) "
24
35
25
36
# If the page contains the line with the hash:
26
- if echo " $PAGE_CONTENT " | grep -q " Build: staging @${TARGET_HASH } " ; then
27
- echo " Found Build: staging @${TARGET_HASH } !"
37
+ if echo " $PAGE_CONTENT " | grep -q " Build: .* @${SHORT_SHA } " ; then
38
+ echo " Found Build: .* @${SHORT_SHA } !"
28
39
exit 0
29
40
fi
30
41
35
46
DELAY=$(( DELAY * 2 ))
36
47
37
48
# cap the delay if a maximum delay is provided
38
- if [ -n " $MAX_DELAY " ] && [ $DELAY -gt $MAX_DELAY ]; then
39
- DELAY=$MAX_DELAY
49
+ if [ -n " $MAX_DELAY " ] && [ " $DELAY " -gt " $MAX_DELAY " ]; then
50
+ DELAY=" $MAX_DELAY "
40
51
fi
41
52
done
0 commit comments