k8sdeploy/k8sdeploy.sh

29 lines
777 B
Bash
Raw Normal View History

2024-04-30 21:08:27 +00:00
#!/bin/bash -e
# shellcheck disable=SC1091
set -a
. ./.env
set +a
REGISTRY="${IMAGEAPP%%/*}"
2024-05-02 15:27:39 +00:00
NS="${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}"
2024-04-30 21:08:27 +00:00
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"
2024-04-30 21:18:19 +00:00
if [ -n "$ACTION_REGISTRY_PASSWORD" ]; then
2024-04-30 21:34:03 +00:00
kubectl get secret regcred \
|| kubectl create secret docker-registry regcred \
--docker-server="$REGISTRY" \
--docker-username="$ACTION_REGISTRY_USERNAME" \
--docker-password="$ACTION_REGISTRY_PASSWORD"
2024-04-30 21:08:27 +00:00
fi
2024-05-02 15:27:39 +00:00
if [ "$GITHUB_REF_NAME" == prod ] || [ "$GITHUB_REF_NAME" == staging ]; then
2024-05-01 10:36:00 +00:00
./manifests/bin/prod.sh
else
./manifests/bin/devel.sh
fi