k8sdeploy/k8sdeploy.sh
2024-05-02 17:27:39 +02:00

29 lines
777 B
Bash
Executable File

#!/bin/bash -e
# shellcheck disable=SC1091
set -a
. ./.env
set +a
REGISTRY="${IMAGEAPP%%/*}"
NS="${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}"
mkdir -p "$HOME/.kube/"
echo "$ACTION_KUBECONFIG" > "$HOME/.kube/config"
kubectl get namespace "$NS" || kubectl create namespace "$NS"
kubectl config set-context --current --namespace="$NS"
if [ -n "$ACTION_REGISTRY_PASSWORD" ]; then
kubectl get secret regcred \
|| kubectl create secret docker-registry regcred \
--docker-server="$REGISTRY" \
--docker-username="$ACTION_REGISTRY_USERNAME" \
--docker-password="$ACTION_REGISTRY_PASSWORD"
fi
if [ "$GITHUB_REF_NAME" == prod ] || [ "$GITHUB_REF_NAME" == staging ]; then
./manifests/bin/prod.sh
else
./manifests/bin/devel.sh
fi