Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
Add deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
deen13 committed Aug 27, 2020
1 parent d3803a0 commit ae93d67
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions deployment/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

if ! type -P gh 1>/dev/null; then
echo "This script requires the github cli to be installed. (https://github.com/cli/cli)"
exit 1
fi

if ! type -P jq 1>/dev/null; then
echo "This script requires jq to be installed. (https://github.com/stedolan/jq)"
exit 1
fi

if ! type -P kustomize 1>/dev/null; then
echo "This script requires kustomize to be installed. (https://github.com/kubernetes-sigs/kustomize)"
exit 1
fi

if ! type -P kubectl 1>/dev/null; then
echo "This script requires kubectl to be installed. (https://kubernetes.io/de/docs/tasks/tools/install-kubectl/)"
exit 1
fi

declare -r version=$(gh api repos/smartsquaregmbh/smidle/releases | jq -r 'first(.[] | select(.draft==false) | select(.prerelease==false)) | .tag_name')

if [[ -z "$version" ]]
then
echo -e "\033[0;31mThere is no production release yet. :(\033[0m"
exit 1
fi

read -p "Do you really want to deploy version $version to production? (y/n) " RESP
if [ "$RESP" = "y" ]; then
kustomize edit set image docker.pkg.github.com/smartsquaregmbh/smidle/smidle-rest-api=docker.pkg.github.com/smartsquaregmbh/smidle/smidle-rest-api:$version
kustomize edit set image docker.pkg.github.com/smartsquaregmbh/smidle/smidle-frontend=docker.pkg.github.com/smartsquaregmbh/smidle/smidle-frontend:$version

kustomize build . | kubectl apply --cluster='leonies-cluster' -f -

git checkout HEAD kustomization.yaml --quiet

echo ""
echo -e "\033[1;32mDone! I got the current deployment status - just for you:\033[0m"
kubectl get deployment --cluster='leonies-cluster' --all-namespaces
else
echo "Phew! That was close..."
fi

0 comments on commit ae93d67

Please sign in to comment.