forked from cyberark/conjur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush-image.sh
executable file
·52 lines (38 loc) · 1.31 KB
/
push-image.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash -e
# Push the 'conjur' image to various Docker registries
# Push stable images on master branch
# Release images can be created by passing the desired tag to this script
# Ex: ./push-image 4.9.5.1
TAG="${1:-$(< VERSION)-$(git rev-parse --short HEAD)}"
SOURCE_IMAGE='conjur'
INTERNAL_IMAGE='registry.tld/conjur'
INTERNAL_IMAGE_NEW='registry.tld/cyberark/conjur' # We'll transition to this
DOCKERHUB_IMAGE='cyberark/conjur'
QUAY_IMAGE='quay.io/cyberark/conjur'
function main() {
echo "TAG = $TAG"
tag_and_push $INTERNAL_IMAGE $TAG
tag_and_push $INTERNAL_IMAGE_NEW $TAG
if [ "$BRANCH_NAME" = "master" ]; then
local latest_tag='latest'
local stable_tag="$(< VERSION)-stable"
echo "TAG = $stable_tag, stable image"
tag_and_push $INTERNAL_IMAGE $latest_tag
tag_and_push $INTERNAL_IMAGE $stable_tag
tag_and_push $INTERNAL_IMAGE_NEW $latest_tag
tag_and_push $INTERNAL_IMAGE_NEW $stable_tag
tag_and_push $DOCKERHUB_IMAGE $TAG
tag_and_push $DOCKERHUB_IMAGE $latest_tag
tag_and_push $DOCKERHUB_IMAGE $stable_tag
tag_and_push $QUAY_IMAGE $TAG
tag_and_push $QUAY_IMAGE $latest_tag
tag_and_push $QUAY_IMAGE $stable_tag
fi
}
function tag_and_push() {
local image="$1"
local tag="$2"
docker tag "$SOURCE_IMAGE" "$image:$tag"
docker push "$image:$tag"
}
main