aboutsummaryrefslogtreecommitdiffstats
path: root/dist/linux/deploy2dockerhub.sh
blob: 63b9fc8d93e8089a148c193942857451121dc1e5 (plain)
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
#! /bin/sh

set -e

. dist/linux/travis-utils.sh
. dist/ansi_color.sh
#disable_color

# Skip deploy if we are in stage 0 (i.e. IMAGE="") and there is no '[ci images]' in the commit message
if [ "$1" = "skip" ] || [ "${1}$(echo $2 | grep -o '\[ci images\]')" = "" ]; then
    printf "${ANSI_GREEN}SKIP DEPLOY2DOCKERHUB$ANSI_NOCOLOR\n";
    exit 0;
fi

case $1 in
  "")    FILTER="/";;
  *)     FILTER="/ghdl /pkg";;
esac

docker login -u="$DOCKER_USER" -p="$DOCKER_PASS"
for key in $FILTER; do
  for tag in `echo $(docker images ghdl$key* | awk -F ' ' '{print $1 ":" $2}') | cut -d ' ' -f2-`; do
      if [ "$tag" = "REPOSITORY:TAG" ]; then break; fi
      echo "travis_fold:start:`echo $tag | grep -oP 'ghdl/\K.*'`"
      travis_time_start
      printf "$ANSI_YELLOW[DOCKER push] ${tag}$ANSI_NOCOLOR\n"
      docker push $tag
      travis_time_finish
      echo "travis_fold:end:`echo $tag | grep -oP 'ghdl/\K.*'`"
  done
done
docker logout