forked from graphprotocol/graph-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag.sh
31 lines (22 loc) · 910 Bytes
/
tag.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
#! /bin/bash
# This script is used by cloud build to push Docker images into Docker hub
tag_and_push() {
tag=$1
docker tag gcr.io/$PROJECT_ID/graph-node:$SHORT_SHA \
graphprotocol/graph-node:$tag
docker push graphprotocol/graph-node:$tag
docker tag gcr.io/$PROJECT_ID/graph-node-debug:$SHORT_SHA \
graphprotocol/graph-node-debug:$tag
docker push graphprotocol/graph-node-debug:$tag
}
echo "Logging into Docker Hub"
echo $PASSWORD | docker login --username="$DOCKER_HUB_USER" --password-stdin
set -ex
tag_and_push "$SHORT_SHA"
# Builds of tags set the tag in Docker Hub, too
[ -n "$TAG_NAME" ] && tag_and_push "$TAG_NAME"
# Builds for tags vN.N.N become the 'latest'
[[ "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && tag_and_push latest
# If the build is from the master branch, tag it as 'nightly'
[ "$BRANCH_NAME" = "master" ] && tag_and_push nightly
exit 0