File: docker_push.sh

package info (click to toggle)
weakforced 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 3,196 kB
  • sloc: cpp: 20,397; python: 2,002; sh: 700; makefile: 432
file content (36 lines) | stat: -rwxr-xr-x 609 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
docker_login()
{
    echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
}
# Only push tagged releases matching the versioning scheme
check_version()
{
    echo $TAG | egrep "^v[0-9]+\.[0-9]+\.[0-9]+"
}

push_tag()
{
  local tag=$1
  echo "Docker username is: '"$DOCKER_USERNAME"'"
  docker_login
  docker push $IMAGE:$tag
}

IMAGE=$1
TAG=`git describe --tags`
check_version
if [ $? = "0" ]
then
    push_tag $TAG
fi


BRANCH=`git branch --show-current`
if [ "$BRANCH" = "master" ]
then
    docker tag $IMAGE:$TAG $IMAGE:unstable
    push_tag unstable
fi

exit 0