forked from alpine-docker/gcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·36 lines (27 loc) · 865 Bytes
/
build.sh
File metadata and controls
executable file
·36 lines (27 loc) · 865 Bytes
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
#!/usr/bin/env bash
# Prerequisite
# Make sure you set secret enviroment variables in Travis CI
# DOCKER_USERNAME
# DOCKER_PASSWORD
# API_TOKEN
# set -ex
image="alpine/gcloud"
sum=0
latest=$(curl -sL curl https://cloud.google.com/sdk/docs/release-notes |awk -F ">" '/tabindex/{print $2}' |awk '{print $1}' |head -1)
echo "Lastest release is: ${latest}"
tags=`curl -s https://hub.docker.com/v2/repositories/${image}/tags/ |jq -r .results[].name`
for tag in ${tags}
do
if [ ${tag} == ${latest} ];then
sum=$((sum+1))
fi
done
if [[ ( $sum -ne 1 ) || ( ${REBUILD} == "true" ) ]];then
docker build -t ${image} --build-arg VERSION=${latest} .
docker tag ${image} ${image}:${latest}
if [[ "$TRAVIS_BRANCH" == "master" ]]; then
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push ${image}
docker push ${image}:${latest}
fi
fi