From 32356cc3877a6b8d3e7a46aab8610b4fb3ea41db Mon Sep 17 00:00:00 2001
From: Bertrand Goareguer <bertrand.goareguer@gmail.com>
Date: Fri, 13 Jan 2023 08:07:17 +0000
Subject: [PATCH] fix(deploy): deploy packaged chart instead of chart file
 (required for chart with dependencies)

---
 templates/gitlab-ci-helm.yml | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/templates/gitlab-ci-helm.yml b/templates/gitlab-ci-helm.yml
index b98f7d6..e9aa612 100644
--- a/templates/gitlab-ci-helm.yml
+++ b/templates/gitlab-ci-helm.yml
@@ -455,16 +455,17 @@ stages:
       helm_opts="$helm_opts --namespace $namespace"
     fi
 
-    chart=${HELM_DEPLOY_CHART:-$HELM_CHART_DIR}
-    if [ -z "${chart}" ]; then
+    package=$(ls -1 ./helm_packages/*.tgz 2>/dev/null || echo "")
+    package=${package:-$HELM_DEPLOY_CHART}
+    if [ -z "${package}" ]; then
       log_error "No Chart to deploy! Please use \\e[32m\$HELM_DEPLOY_CHART\\e[0m to deploy a chart from a repository"
       log_error "Or check the provided variables to package your own chart!"
       exit 1
     fi
-    log_info "--- using \\e[32mchart\\e[0m: \\e[33;1m${chart}\\e[0m"
+    log_info "--- using \\e[32mpackage\\e[0m: \\e[33;1m${package}\\e[0m"
 
     # shellcheck disable=SC2086
-    helm $helm_opts $HELM_DEPLOY_ARGS $environment_name $chart
+    helm $helm_opts $HELM_DEPLOY_ARGS $environment_name $package
 
     # maybe execute post deploy script
     postscript="$HELM_SCRIPTS_DIR/helm-post-deploy.sh"
-- 
GitLab