This repository was archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpush-image
More file actions
executable file
·46 lines (36 loc) · 1.4 KB
/
push-image
File metadata and controls
executable file
·46 lines (36 loc) · 1.4 KB
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
#!/bin/bash
set -e
readonly REGISTRY="cyberark"
readonly INTERNAL_REGISTRY="registry2.itci.conjur.net"
readonly VERSION="$(cat VERSION)"
readonly VERSION_TAG="5-${VERSION}"
readonly image_name="conjur-cli"
readonly full_image_name="${REGISTRY}/${image_name}:latest"
readonly TAGS=(
"5"
"5-latest"
"$VERSION_TAG"
)
# fetching tags is required for git_description to work
git fetch --tags
git_description=$(git describe)
# if it’s not a tagged commit, VERSION will have extra junk (i.e. -g666c4b2), so we won’t publish that commit
# only when tag matches the VERSION, push VERSION and latest releases
# and x and x.y releases
#Ex: v5-6.2.1
if [ "${git_description}" = "v${VERSION}" ]; then
echo "Revision ${git_description} matches version ${VERSION} exactly. Pushing to Dockerhub..."
for tag in "${TAGS[@]}"; do
echo "Tagging and pushing ${REGISTRY}/${image_name}:${tag}"
# push to dockerhub
docker tag "${full_image_name}" "${REGISTRY}/${image_name}:${tag}"
docker push "${REGISTRY}/${image_name}:${tag}"
# push to internal registry
# necessary because some cyberark teams/networks can't pull from dockerhub
docker tag "${full_image_name}" "${INTERNAL_REGISTRY}/${image_name}:${tag}"
docker push "${INTERNAL_REGISTRY}/${image_name}:${tag}"
done
# push to legacy `conjurinc/cli5` tag
docker tag "${full_image_name}" conjurinc/cli5:latest
docker push conjurinc/cli5:latest
fi