-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtravis-deploy.sh
executable file
·73 lines (61 loc) · 1.9 KB
/
travis-deploy.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
set -e
image="mikesir87/swarm-viz"
docker tag $image "$image:linux-$ARCH-$TRAVIS_COMMIT"
docker push "$image:linux-$ARCH-$TRAVIS_COMMIT"
deploy() {
sleep 15
echo "Pushing manifest $image:latest"
./manifest-tool push from-args \
--platforms linux/amd64,linux/s390x \
--template "$image:OS-ARCH-$TRAVIS_COMMIT" \
--target "$image:latest"
}
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
travis_retry() {
local result=0
local count=1
while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
}
# ! { } ignores set -e, see https://stackoverflow.com/a/4073372
! { "$@"; result=$?; }
[ $result -eq 0 ] && break
count=$(($count + 1))
sleep 1
done
[ $count -gt 3 ] && {
echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
}
return $result
}
if [ "$ARCH" == "amd64" ]; then
set +e
echo "Waiting for other images $image:linux-s390"
until docker run --rm stefanscherer/winspector "$image:linux-s390x-$TRAVIS_COMMIT"
do
sleep 15
echo "Trying again..."
done
# echo "Waiting for other images $image:windows-amd64"
# until docker run --rm stefanscherer/winspector "$image:windows-amd64"
# do
# sleep 15
# echo "Trying again..."
# done
set -e
echo "Downloading docker client with manifest command"
wget https://5028-88013053-gh.circle-artifacts.com/1/work/build/docker-linux-amd64
mv docker-linux-amd64 docker
chmod +x docker
./docker version
set -x
echo "Downloading manifest-tool"
wget https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64
mv manifest-tool-linux-amd64 manifest-tool
chmod +x manifest-tool
./manifest-tool --version
echo "Pushing manifest $image:$TRAVIS_TAG"
travis_retry deploy
fi