From cd0d87542a4283812575ffb3fbc1dca0d7137a1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Batuhan=20Apayd=C4=B1n?= <batuhan.apaydin@trendyol.com>
Date: Thu, 1 Sep 2022 22:15:33 +0300
Subject: [PATCH] chore: publish helm charts to ghcr.io (#4479)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
---
 .github/workflows/helm-release.yaml | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/helm-release.yaml b/.github/workflows/helm-release.yaml
index 70595fb42e..f21268f5f2 100644
--- a/.github/workflows/helm-release.yaml
+++ b/.github/workflows/helm-release.yaml
@@ -37,7 +37,7 @@ jobs:
       - name: Install Helm
         uses: azure/setup-helm@18bc76811624f360dbd7f18c2d4ecb32c7b87bab # v1.1
         with:
-          version: v3.4.1
+          version: v3.8.0
 
       - name: Set version
         run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
@@ -58,3 +58,16 @@ jobs:
           token: "${{ secrets.GITHUB_TOKEN }}"
           linting: off
           charts_dir: charts-tmp
+
+      - name: Login to GitHub Container Registry
+        run: |
+          helm registry login --username ${GITHUB_ACTOR} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io
+      
+      - name: Publish OCI Charts
+        run: |
+          for dir in `find charts-tmp -maxdepth 1 -mindepth 1 -type d -print`; do
+            chart=${dir##*/}
+            echo "Found chart: ${chart}"
+            helm package charts-tmp/${chart} --destination dist
+            helm push dist/${chart}-*.tgz oci://ghcr.io/${GITHUB_REPOSITORY}
+          done
\ No newline at end of file