test of deployment
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -15,6 +15,9 @@ jobs:
|
||||
env:
|
||||
REGISTRY: gitea.dataprovider01.sandbox-cat-dat.simpl-europe.eu
|
||||
IMAGE_REPO: gitea.dataprovider01.sandbox-cat-dat.simpl-europe.eu/j.r/template-code-location
|
||||
K8S_NAMESPACE: dataprovider01
|
||||
HELM_RELEASE: dataprovider01-dataprovider-orchestration-platform
|
||||
DAGSTER_CHART_VERSION: 0.2.0
|
||||
steps:
|
||||
- name: Checkout repository (shell)
|
||||
run: |
|
||||
@@ -72,3 +75,60 @@ jobs:
|
||||
SHORT_SHA="$(echo "${COMMIT_SHA}" | cut -c1-12)"
|
||||
docker push "${IMAGE_REPO}:latest"
|
||||
docker push "${IMAGE_REPO}:${SHORT_SHA}"
|
||||
|
||||
- name: Install helm and kubectl
|
||||
run: |
|
||||
ARCH="$(uname -m)"
|
||||
if [ "${ARCH}" = "x86_64" ]; then
|
||||
ARCH="amd64"
|
||||
elif [ "${ARCH}" = "aarch64" ]; then
|
||||
ARCH="arm64"
|
||||
fi
|
||||
|
||||
if ! command -v helm >/dev/null 2>&1; then
|
||||
apk add --no-cache curl tar gzip ca-certificates
|
||||
HELM_VERSION="v3.16.4"
|
||||
curl -fsSL "https://get.helm.sh/helm-${HELM_VERSION}-linux-${ARCH}.tar.gz" -o /tmp/helm.tgz
|
||||
tar -xzf /tmp/helm.tgz -C /tmp
|
||||
mv "/tmp/linux-${ARCH}/helm" /usr/local/bin/helm
|
||||
chmod +x /usr/local/bin/helm
|
||||
fi
|
||||
|
||||
if ! command -v kubectl >/dev/null 2>&1; then
|
||||
KUBECTL_VERSION="v1.31.2"
|
||||
curl -fsSL "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl" -o /usr/local/bin/kubectl
|
||||
chmod +x /usr/local/bin/kubectl
|
||||
fi
|
||||
|
||||
helm version
|
||||
kubectl version --client
|
||||
|
||||
- name: Deploy to Dagster with Helm
|
||||
run: |
|
||||
if [ -z "${{ secrets.KUBE_CONFIG_B64 }}" ]; then
|
||||
echo "Missing KUBE_CONFIG_B64 secret"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMMIT_SHA="${GITHUB_SHA:-$GITEA_SHA}"
|
||||
SHORT_SHA="$(echo "${COMMIT_SHA}" | cut -c1-12)"
|
||||
|
||||
mkdir -p "${HOME}/.kube"
|
||||
echo "${{ secrets.KUBE_CONFIG_B64 }}" | base64 -d > "${HOME}/.kube/config"
|
||||
export KUBECONFIG="${HOME}/.kube/config"
|
||||
|
||||
helm upgrade --install "${HELM_RELEASE}" dagster \
|
||||
--repo "https://code.europa.eu/api/v4/projects/1304/packages/helm/stable" \
|
||||
--version "${DAGSTER_CHART_VERSION}" \
|
||||
--namespace "${K8S_NAMESPACE}" \
|
||||
--reuse-values \
|
||||
--set-string "dagster.dagster-user-deployments.deployments[0].image.repository=${IMAGE_REPO}" \
|
||||
--set-string "dagster.dagster-user-deployments.deployments[0].image.tag=${SHORT_SHA}"
|
||||
|
||||
DEPLOYMENT_NAME="$(kubectl -n "${K8S_NAMESPACE}" get deployment -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep 'template-code-location' | head -n 1)"
|
||||
if [ -n "${DEPLOYMENT_NAME}" ]; then
|
||||
kubectl -n "${K8S_NAMESPACE}" rollout restart "deployment/${DEPLOYMENT_NAME}"
|
||||
kubectl -n "${K8S_NAMESPACE}" rollout status "deployment/${DEPLOYMENT_NAME}" --timeout=300s
|
||||
else
|
||||
echo "No deployment name matched template-code-location; Helm upgrade completed without explicit rollout restart."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user