-
Notifications
You must be signed in to change notification settings - Fork 531
/
docker_tag_alias.sh
executable file
·34 lines (28 loc) · 1.2 KB
/
docker_tag_alias.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
#!/bin/bash -x
# Tags an image FLAVOR as ALIAS
#
# ./docker_tag_alias.sh FLAVOR ALIAS
#
# Docker password is in a file /tmp/docker.pass
# because this script uses -x for build transparency
# but we don't want to leak passwords
set -e
FLAVOR="$1"
ALIAS="$2"
cat /tmp/docker.pass | docker login -u="$DOCKER_USERNAME" --password-stdin
if [[ "$TRAVIS_BRANCH" == "master" ]] ; then
docker pull $DOCKER_ORG/openresty:$FLAVOR &&
docker tag $DOCKER_ORG/openresty:$FLAVOR $DOCKER_ORG/openresty:$ALIAS &&
docker push $DOCKER_ORG/openresty:$ALIAS ;
fi
if [[ "$TRAVIS_TAG" ]] ; then
TRAVIS_TAG_BASE=$(echo -n "$TRAVIS_TAG" | sed 's/-[0-9]$//g') ;
if [[ ( "$TRAVIS_TAG_BASE" ) && ( "$TRAVIS_TAG_BASE" != "$TRAVIS_TAG" ) ]] ; then
docker pull $DOCKER_ORG/openresty:$TRAVIS_TAG_BASE-$FLAVOR &&
docker tag $DOCKER_ORG/openresty:$TRAVIS_TAG_BASE-$FLAVOR $DOCKER_ORG/openresty:$TRAVIS_TAG_BASE-$ALIAS &&
docker push $DOCKER_ORG/openresty:$TRAVIS_TAG_BASE-$ALIAS ;
fi ;
docker pull $DOCKER_ORG/openresty:$TRAVIS_TAG-$FLAVOR &&
docker tag $DOCKER_ORG/openresty:$TRAVIS_TAG-$FLAVOR $DOCKER_ORG/openresty:$TRAVIS_TAG-$ALIAS &&
docker push $DOCKER_ORG/openresty:$TRAVIS_TAG-$ALIAS ;
fi