Skip to content
name: Build & Publish Helm Charts to GHCR
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
build-and-publish-helm-charts:
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
go install sigs.k8s.io/kustomize/kustomize/v5@latest
go install github.com/arttor/helmify/cmd/helmify@latest
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Create temporary directory
run: mkdir -p /tmp/helm-charts
- name: Create output directory
run: mkdir -p /tmp/helm-packages
- name: Copy kode-crd to temporary directory
run: cp -r helm-charts/kode-crd /tmp/helm-charts/kode-crd
- name: Update Chart.yaml for kode-crd
run: |
sed -i "s/v0.0.0-latest/${{ env.VERSION }}/g" /tmp/helm-charts/kode-crd/Chart.yaml
sed -i "s/v0.0.0-latest/${{ env.VERSION }}/g" /tmp/helm-charts/kode-crd/README.md
sed -i "s/v0.0.0--latest/${{ env.VERSION }}/g" /tmp/helm-charts/kode-crd/README.md # Special case for the img.shields.io bagde
helm package /tmp/helm-charts/kode-crd --version ${{ env.VERSION }} --destination /tmp/helm-packages
- name: Push kode-crd chart
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login -u ${{ github.actor }} ghcr.io --password-stdin
helm push /tmp/helm-packages/kode-crd-${{ env.VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
- name: Copy kode to temporary directory
run: cp -r helm-charts/kode /tmp/helm-charts/kode
- name: Update Chart.yaml and values.yaml for kode
run: |
sed -i "s/v0.0.0-latest/${{ env.VERSION }}/g" /tmp/helm-charts/kode/Chart.yaml
sed -i "s/v0.0.0-latest/${{ env.VERSION }}/g" /tmp/helm-charts/kode/values.yaml
sed -i "s/v0.0.0-latest/${{ env.VERSION }}/g" /tmp/helm-charts/kode/README.md
sed -i "s/v0.0.0--latest/${{ env.VERSION }}/g" /tmp/helm-charts/kode/README.md # Special case for the img.shields.io bagde
helm dependency update /tmp/helm-charts/kode
helm package /tmp/helm-charts/kode --version ${{ env.VERSION }} --destination /tmp/helm-packages
- name: Push kode chart
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login -u ${{ github.actor }} ghcr.io --password-stdin
helm push /tmp/helm-packages/kode-${{ env.VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
- name: Clean up temporary directory
run: rm -rf /tmp/helm-charts /tmp/helm-packages
- name: Log out from GitHub Container Registry
run: helm registry logout ghcr.io