1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

Automatically deploy on new tags on k8s

This commit is contained in:
Javier Cortejoso 2019-04-09 11:07:45 +02:00
parent 72741f5ae6
commit a02ad0fc97
No known key found for this signature in database
GPG Key ID: FBEEF3131E39EBCF
2 changed files with 50 additions and 0 deletions

View File

@ -20,3 +20,9 @@ deploy:
tags: true
all_branches: true
- provider: script
skip_cleanup: true
script: bash -ex ./scripts/deploy_on_k8s.sh
on:
tags: true
all_branches: true

44
scripts/deploy_on_k8s.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
if [ -z "${TRAVIS_TAG}" ]; then
echo "Variable \$TRAVIS_TAG not set or empty. Skiping deploying new version on k8s"
exit 0
fi
if ! [[ "${TRAVIS_TAG}" =~ ^v[0-9]\.[0-9]\.[0-9]$ ]]; then
echo "Variable \$TRAVIS_TAG does not match with vx.y.z format. Skiping deploying new version on k8s"
exit 0
fi
curl -L https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -o /tmp/kubectl
chmod +x /tmp/kubectl
mkdir -p ~/.kube
cat<<EOF > ~/.kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ${KUBE_CERTIFICATE_AUTHORITY_DATA}
server: ${KUBE_SERVER}
name: cluster
contexts:
- context:
cluster: cluster
namespace: ${KUBE_NAMESPACE}
user: ${KUBE_USER}
name: cluster
current-context: cluster
kind: Config
preferences: {}
users:
- name: ${KUBE_USER}
user:
client-key-data: ${KUBE_CLIENT_KEY_DATA}
token: ${KUBE_TOKEN}
EOF
# Patch deployed versions in k8s cluster
/tmp/kubectl patch deployment marketplace-client-commons -p\
"{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"marketplace-commons\",\"image\":\"oceanprotocol/commons_client:${TRAVIS_TAG}\"}]}}}}"
/tmp/kubectl patch deployment marketplace-server-commons -p\
"{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"marketplac-server-commons\",\"image\":\"oceanprotocol/commons_server:${TRAVIS_TAG}\"}]}}}}"