2021-07-12 20:14:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Prerequisites:
|
|
|
|
#
|
2022-10-19 22:31:47 +00:00
|
|
|
# - Log in to the DigitalOcean API, either interactively, by running
|
|
|
|
# `doctl auth init`, or by setting the `DIGITALOCEAN_ACCESS_TOKEN`
|
|
|
|
# environment variable.
|
2021-07-12 20:14:39 +00:00
|
|
|
|
2021-09-29 21:08:53 +00:00
|
|
|
set -eu
|
2021-07-12 20:14:39 +00:00
|
|
|
|
2022-10-19 22:31:47 +00:00
|
|
|
if [[ $# < 2 ]]; then
|
|
|
|
echo "Usage: $0 <production|staging|preview> <tag-name>"
|
2021-09-29 21:08:53 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
export ZED_KUBE_NAMESPACE=$1
|
2022-10-19 22:31:47 +00:00
|
|
|
COLLAB_VERSION=$2
|
|
|
|
|
2022-04-12 00:18:12 +00:00
|
|
|
ENV_FILE="crates/collab/k8s/environments/${ZED_KUBE_NAMESPACE}.sh"
|
2021-09-29 21:08:53 +00:00
|
|
|
if [[ ! -f $ENV_FILE ]]; then
|
|
|
|
echo "Invalid environment name '${ZED_KUBE_NAMESPACE}'"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-10-19 22:31:47 +00:00
|
|
|
export $(cat $ENV_FILE)
|
2021-09-29 21:08:53 +00:00
|
|
|
|
2022-10-19 22:31:47 +00:00
|
|
|
if [[ ! $COLLAB_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
|
|
echo "Invalid version number '$COLLAB_VERSION'"
|
2021-09-29 21:08:53 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-10-19 22:31:47 +00:00
|
|
|
TAG_NAMES=$(doctl registry repository list-tags collab --no-header --format Tag)
|
|
|
|
if ! $(echo "${TAG_NAMES}" | grep -Fqx v${COLLAB_VERSION}); then
|
|
|
|
echo "No such image tag: 'zed/collab:v${COLLAB_VERSION}'"
|
|
|
|
echo "Found tags"
|
|
|
|
echo "${TAG_NAMES}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
export ZED_IMAGE_ID="registry.digitalocean.com/zed/collab:v${COLLAB_VERSION}"
|
2021-09-29 21:08:53 +00:00
|
|
|
|
2022-10-19 22:31:47 +00:00
|
|
|
if [[ $(kubectl config current-context 2> /dev/null) != do-nyc1-zed-1 ]]; then
|
|
|
|
doctl kubernetes cluster kubeconfig save zed-1
|
|
|
|
fi
|
2021-09-29 21:08:53 +00:00
|
|
|
|
2022-04-12 00:18:12 +00:00
|
|
|
envsubst < crates/collab/k8s/manifest.template.yml | kubectl apply -f -
|