Publish Helm Chart #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Helm Chart | |
# Trigger on release events for main and helm-chart branches | |
on: | |
release: | |
types: [published] | |
branches: | |
- main | |
- helm-chart | |
env: | |
REGISTRY: ghcr.io | |
CHART_DIR: chart | |
HELM_VERSION: v3.12.3 | |
jobs: | |
build: | |
name: Build and Validate Chart | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: ${{ env.HELM_VERSION }} | |
- name: Update chart version | |
run: | | |
# Extract version from release tag | |
VERSION=${GITHUB_REF#refs/tags/} | |
echo "Setting chart version to: ${VERSION}" | |
yq e -i '.version = "'${VERSION}'"' ${{ env.CHART_DIR }}/Chart.yaml | |
- name: Lint chart | |
run: helm lint ${{ env.CHART_DIR }} | |
- name: Validate chart template | |
run: helm template ${{ env.CHART_DIR }} | |
- name: Package chart | |
run: helm package ${{ env.CHART_DIR }} | |
- name: Upload chart artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: helm-chart | |
path: ./*.tgz | |
retention-days: 1 | |
publish: | |
name: Publish to Registry | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Download chart artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: helm-chart | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push chart to registry | |
run: | | |
echo "Publishing Helm chart to ${{ env.REGISTRY }}/${{ github.repository_owner }}" | |
helm push *.tgz oci://${{ env.REGISTRY }}/${{ github.repository_owner }} |