Skip to content

Commit facdfd8

Browse files
authored
Workflow for publishing a Helm chart to GitHub Container Registry (ghcr.io) (#12)
Signed-off-by: Andy Bavier <andybavier@gmail.com>
1 parent 900f821 commit facdfd8

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: 2025 Andy Bavier <andybavier@gmail.com>
3+
4+
name: Publish Helm Chart to GitHub OCI Registry
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
chart_path:
10+
description: 'Path to the Helm chart directory to publish'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
publish-ghcr:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Install Helm
25+
uses: azure/setup-helm@v4
26+
27+
- name: Build chart dependencies
28+
run: |
29+
helm dep build ${{ inputs.chart_path }}
30+
31+
- name: Package Helm chart
32+
run: |
33+
helm package ${{ inputs.chart_path }}
34+
35+
- name: Login to GitHub Container Registry
36+
run: |
37+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
38+
39+
- name: Push chart to GHCR
40+
run: |
41+
# Convert owner name to lowercase for the registry URL
42+
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
43+
CHART_NAME=$(basename ${{ inputs.chart_path }})
44+
helm push ${CHART_NAME}-*.tgz oci://ghcr.io/$OWNER
45+
46+
- name: Logout from GHCR
47+
if: always()
48+
run: |
49+
helm registry logout ghcr.io

0 commit comments

Comments
 (0)