-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·54 lines (45 loc) · 944 Bytes
/
entrypoint.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
52
53
54
#!/bin/bash
set -e
USER=$1
PASSWORD=$2
ARTIFACT=$3
URL=$4
DELAY=$5
if [ -z $USER ]; then
echo 'Required username parameter'
exit 1
fi
if [ -z $PASSWORD ]; then
echo 'Required password parameter'
exit 1
fi
if [ -z $URL ]; then
echo 'Required repository parameter'
exit 1
fi
if [ -z $ARTIFACT ]; then
echo 'Required repository parameter'
exit 1
fi
function fail {
echo $1 >&2
break;
}
function run {
local n=1
local max=3
while true; do
"$@" && break || {
if [[ $n -lt $max ]]; then
((n++))
echo ::set-output name=output::"Upload failed. Attempt $n/$max:"
sleep $DELAY;
else
fail ::set-output name=output::"The upload has failed after $n attempts."
fi
}
done
}
echo "Artifact to upload: $ARTIFACT"
run curl -X PUT -u $USER:$PASSWORD -T $ARTIFACT $URL
echo ::set-output name=output::"Artifact deployed"