From d57909826f518254e2738b4c01558f34086bd854 Mon Sep 17 00:00:00 2001
From: Maarten de Waard <maarten@greenhost.nl>
Date: Wed, 8 Dec 2021 16:46:06 +0100
Subject: [PATCH] use empty CHART_DIR string but do not break other commands

---
 .gitlab/ci_templates/helm_package.yml | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/.gitlab/ci_templates/helm_package.yml b/.gitlab/ci_templates/helm_package.yml
index c31d7a3da..90f306925 100644
--- a/.gitlab/ci_templates/helm_package.yml
+++ b/.gitlab/ci_templates/helm_package.yml
@@ -4,7 +4,7 @@
 # 1. CHART_NAME: the name of the helm chart. Should correspond to the name in
 #    Chart.yaml
 # 2. CHART_DIR (optional): the directory where your helm chart is in you
-#    repository.  Defaults to '.'
+#    repository. HAS TO END WITH A SLASH if you choose to override it.
 
 variables:
   CHART_DIR: ""
@@ -20,19 +20,19 @@ lint-helm:
     name: alpine/helm:3.7.1
     entrypoint: ["/bin/sh", "-c"]
   script:
-    - cd ${CHART_DIR}
+    - cd ${CHART_DIR:-"."}
     - helm dep update
     - helm lint .
   artifacts:
     paths:
-      - '${CHART_DIR}/charts/**'
+      - '${CHART_DIR}charts/**'
     expire_in: 1 week
     # Even if lint fails, upload the charts/ folder as artifact
     when: always
   rules:
     - changes:
-      - '${CHART_DIR}/*.yaml'
-      - ${CHART_DIR}/templates/*.yaml
+      - '${CHART_DIR}*.yaml'
+      - ${CHART_DIR}templates/*.yaml
 
 package-chart:
   stage: package-helm-chart
@@ -40,11 +40,11 @@ package-chart:
     name: alpine/helm:3.7.1
     entrypoint: ["/bin/sh", "-c"]
   script:
-    - cd ${CHART_DIR}
+    - cd ${CHART_DIR:-"."}
     - helm package .
   artifacts:
     paths:
-      - ${CHART_DIR}/${CHART_NAME}-*
+      - ${CHART_DIR}${CHART_NAME}-*
     expire_in: 1 week
   extends:
     - .chart_release_rules
@@ -55,7 +55,7 @@ release-helm:
   image: "rancher/curlimages-curl:7.73.0"
   stage: release-helm-chart
   script:
-    - cd ${CHART_DIR}
+    - cd ${CHART_DIR:-"."}
     - if [ "$CI_COMMIT_BRANCH" == "main" ]; then export HELM_CHANNEL='stable'; else export HELM_CHANNEL='unstable'; fi
     - export CHART_FILE=$(ls ${CHART_NAME}-*.tgz)
     - curl --fail --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@${CHART_FILE}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/${HELM_CHANNEL}/charts"
-- 
GitLab