-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
65 lines (57 loc) · 1.91 KB
/
deploy.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
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
set -e
env
# compatibility with travis and bitbucket
if [ ! -z ${BITBUCKET_TAG} ]
then
echo "assigning bitbucket tag"
export TAG="$BITBUCKET_TAG"
elif [ ! -z ${TRAVIS_TAG} ]
then
echo "assigning travis tag"
export TAG="$TRAVIS_TAG"
elif [ ! -z ${GITHUB_TAG} ]
then
echo "assigning github tag"
export TAG="$GITHUB_TAG"
else
echo No Tag is set!
exit 1
fi
echo "Tag is '${TAG}'"
#check if deployment is triggered only in master
if [ ${BITBUCKET_BRANCH} != "master" ]; then
echo Deploy on tagged commit can be only executed in master!
exit 1
fi
# Obtain the component repository and log in
echo "Obtain the component repository and log in"
docker pull quay.io/keboola/developer-portal-cli-v2:latest
export REPOSITORY=`docker run --rm \
-e KBC_DEVELOPERPORTAL_USERNAME \
-e KBC_DEVELOPERPORTAL_PASSWORD \
quay.io/keboola/developer-portal-cli-v2:latest \
ecr:get-repository ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP}`
echo "Set credentials"
eval $(docker run --rm \
-e KBC_DEVELOPERPORTAL_USERNAME \
-e KBC_DEVELOPERPORTAL_PASSWORD \
quay.io/keboola/developer-portal-cli-v2:latest \
ecr:get-login ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP})
# Push to the repository
echo "Push to the repository"
docker tag ${APP_IMAGE}:latest ${REPOSITORY}:${TAG}
docker tag ${APP_IMAGE}:latest ${REPOSITORY}:latest
docker push ${REPOSITORY}:${TAG}
docker push ${REPOSITORY}:latest
# Update the tag in Keboola Developer Portal -> Deploy to KBC
if echo ${TAG} | grep -c '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$'
then
docker run --rm \
-e KBC_DEVELOPERPORTAL_USERNAME \
-e KBC_DEVELOPERPORTAL_PASSWORD \
quay.io/keboola/developer-portal-cli-v2:latest \
update-app-repository ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP} ${TAG} ecr ${REPOSITORY}
else
echo "Skipping deployment to KBC, tag ${TAG} is not allowed."
fi