forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-docker-push
executable file
·32 lines (25 loc) · 1.18 KB
/
build-docker-push
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/bash -e
# docker build, tag, and push a docker image to quay.io/coreos/tectonic-console
# Will push a sha-named image at every run, will tag that image as "latest"
# if it appears to be the tip of master, will tag that image with a
# git tag if one is present.
# This script relies on .dockercfg or other external configuration to
# grant the appropriate permissions and identity for pushing images to
# quay.io/coreos/tectonic-console
git_status=$(git status --porcelain 2> /dev/null)
git_sha=$(git rev-parse HEAD)
git_tag=$(git tag -l --points-at HEAD)
if [[ "$git_status" != "" ]]; then
echo "Won't push from a dirty git repo. Commit your changes before you push."
exit
fi
docker build -q --rm=true -t quay.io/coreos/tectonic-console:$git_sha .
docker push quay.io/coreos/tectonic-console:$git_sha
if git diff --quiet HEAD origin/master; then
docker tag -f quay.io/coreos/tectonic-console:$git_sha quay.io/coreos/tectonic-console:latest
docker push quay.io/coreos/tectonic-console:latest
fi
if [ ! -z "${git_tag}" ]; then
docker tag -f quay.io/coreos/tectonic-console:$git_sha quay.io/coreos/tectonic-console:$git_tag
docker push quay.io/coreos/tectonic-console:$git_tag
fi