Skip to content

Package and publish Helm chart to GHCR with input #2

Package and publish Helm chart to GHCR with input

Package and publish Helm chart to GHCR with input #2

name: Package and publish Helm chart to GHCR with input
on:
workflow_dispatch:
inputs:
chartDir:
description: 'Directory containing the Helm chart to package and publish'
required: true
type: string
dry-run:
description: 'Run the workflow without pushing the Helm chart to the registry'
type: boolean
required: false
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
ACTIONS_RUNNER_DEBUG: false
jobs:
helm-release:
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up Helm
uses: azure/[email protected]
- uses: actions/setup-python@v5
with:
check-latest: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (lint)
run: ct lint --chart-yaml-schema ci/chart_schema.yaml --lint-conf ci/lintconf.yaml --config ci/config.yaml --chart-dirs ${{ inputs.chartDir }}
- name: Push Charts to GHCR
run: |
helm dependency update ${{ inputs.chartDir }}
helm package ${{ inputs.chartDir }} -d ${{ inputs.chartDir }}
PKG_NAME=$(ls ${{ inputs.chartDir }}/*.tgz)
if [ ${{ inputs.dry-run }} == 'true' ]; then
echo "Dry run: Skipping push of $PKG_NAME"
exit 0
else
helm push ${PKG_NAME} oci://${{ env.REGISTRY }}/${{ github.repository }}/
fi