-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-push.sh
executable file
·37 lines (28 loc) · 1.12 KB
/
docker-push.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
34
35
36
37
#!/bin/bash
set -eu
set -o pipefail
if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
echo "This is a pull request. Don't push."
exit 0
fi
if [ -z "${TRAVIS_TAG}" ]; then
echo "This is not a tag build. Don't push."
exit 0
fi
# gcloud key
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
# gcloud sdk repo
echo "deb https://packages.cloud.google.com/apt cloud-sdk-$(lsb_release -c -s) main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# install gcloud
sudo apt-get update && sudo apt-get install google-cloud-sdk
# init gcloud auth
gcloud config set project paperhive-c0ff33
openssl aes-256-cbc -K $encrypted_852bd548ac03_key -iv $encrypted_852bd548ac03_iv -in gcloud-secret.json.enc -out gcloud-secret.json -d
gcloud auth activate-service-account --key-file gcloud-secret.json
gcloud auth configure-docker --quiet
DOCKER_PREFIX="gcr.io/paperhive-c0ff33"
DOCKER_TAG="${TRAVIS_TAG#v}"
DOCKER_IMAGE_SOURCE="widget"
DOCKER_IMAGE_TARGET="${DOCKER_PREFIX}/${DOCKER_IMAGE_SOURCE}:${DOCKER_TAG}"
docker tag ${DOCKER_IMAGE_SOURCE} ${DOCKER_IMAGE_TARGET}
docker push ${DOCKER_IMAGE_TARGET}