From 2ff6bb34b201999d562cfe6eb3bfff8c24fe56d9 Mon Sep 17 00:00:00 2001 From: Lorenzo Venerandi Date: Thu, 22 Jan 2026 10:51:11 +0100 Subject: [PATCH] feat: add GitHub Actions workflow for packaging and pushing Helm charts --- .github/workflows/helm-package-push.yml | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/helm-package-push.yml diff --git a/.github/workflows/helm-package-push.yml b/.github/workflows/helm-package-push.yml new file mode 100644 index 0000000..8cd119a --- /dev/null +++ b/.github/workflows/helm-package-push.yml @@ -0,0 +1,75 @@ +name: Package and Push Helm Chart + +on: + push: + branches: + - main + - beta + - dev + paths: + - 'helm/**' + tags: + - 'v*' + release: + types: + - published + - created + workflow_dispatch: + +env: + REGISTRY: ${{ vars.DOCKER_REGISTRY }} + +jobs: + package-and-push: + runs-on: self-hosted + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Helm + uses: azure/setup-helm@v4 + with: + version: 'latest' + + - name: Log in to Container Registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin + + - name: Extract version from Chart.yaml + id: version + run: | + VERSION=$(grep '^version:' ./helm/Chart.yaml | awk '{print $2}' | tr -d '"') + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Package Helm chart + run: | + helm package ./helm + + - name: Push Helm chart to registry + run: | + CHART_VERSION=$(grep '^version:' ./helm/Chart.yaml | awk '{print $2}') + CHART_FILE=$(grep '^name:' ./helm/Chart.yaml | awk '{print $2}') + CHART_PATH="${CHART_FILE}-${CHART_VERSION}.tgz" + + # Determine tag based on branch + if [[ "${{ github.ref_name }}" == "main" ]]; then + TAG="${{ steps.version.outputs.version }}" + helm push "$CHART_PATH" oci://${{ env.REGISTRY }}/$CHART_FILE:$TAG + helm push "$CHART_PATH" oci://${{ env.REGISTRY }}/$CHART_FILE:latest + else + TAG="${{ steps.version.outputs.version }}-${{ github.ref_name }}" + helm push "$CHART_PATH" oci://${{ env.REGISTRY }}/$CHART_FILE:$TAG + fi + + - name: Chart pushed + run: | + CHART_FILE=$(grep '^name:' ./helm/Chart.yaml | awk '{print $2}') + if [[ "${{ github.ref_name }}" == "main" ]]; then + echo "Chart pushed: $CHART_FILE:${{ steps.version.outputs.version }} and $CHART_FILE:latest" + else + echo "Chart pushed: $CHART_FILE:${{ steps.version.outputs.version }}-${{ github.ref_name }}" + fi