forked from inspirehep/inspire-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·34 lines (26 loc) · 836 Bytes
/
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
#!/bin/bash -e
retry() {
"$@" || "$@" || exit 2
}
if [[ "$DOCKER_USERNAME" == "" ]] || [[ "$TRAVIS_PULL_REQUEST" == "true" ]]; then
echo "Not in an official branch, skipping deploy"
echo "TRAVIS_SECURE_ENV_VARS=$TRAVIS_SECURE_ENV_VARS"
echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"
exit 0
fi
# fail on unset variables expansion
set -o nounset
if [[ "$TRAVIS_BRANCH" == "master" ]]; then
REMOTE_TAG="$DOCKER_PROJECT:$DOCKER_IMAGE_TAG"
else
REMOTE_TAG="$DOCKER_PROJECT:dev.$TRAVIS_BRANCH-$DOCKER_IMAGE_TAG"
fi
echo "Logging into Docker Hub with user $DOCKER_USERNAME"
retry docker login \
"--password=$DOCKER_PASSWORD" \
"--email=$DOCKER_EMAIL" \
"--username=$DOCKER_USERNAME"
echo "Pushing image to ${REMOTE_TAG}"
retry docker push "${REMOTE_TAG}"
echo "Logging out"
retry docker logout