Skip to content

Commit 34a3d0d

Browse files
Add GitHub Actions workflow to publish Helm chart
Introduce a workflow that packages and pushes the Helm chart to ghcr.io as an OCI artifact. Release tags use semantic versioning while branch builds use commit-based versions. PRs only validate the chart package.
1 parent 21c0a87 commit 34a3d0d

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and IronCore contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Helm Chart
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
branches:
11+
- main
12+
paths-ignore:
13+
- 'docs/**'
14+
- '**/*.md'
15+
pull_request:
16+
branches:
17+
- main
18+
paths-ignore:
19+
- 'docs/**'
20+
- '**/*.md'
21+
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
jobs:
27+
build-and-push-chart:
28+
name: Build and Push Helm Chart
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v6
32+
- name: Set up Helm
33+
uses: azure/setup-helm@v4
34+
with:
35+
version: v4.1.0
36+
- name: Determine Chart Version
37+
id: chart_version
38+
run: |
39+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
40+
# Use tag version (strip 'v' prefix)
41+
CHART_VERSION="${GITHUB_REF#refs/tags/v}"
42+
else
43+
# Use short commit hash
44+
CHART_VERSION="0.0.0-$(git rev-parse --short HEAD)"
45+
fi
46+
echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT
47+
- name: Build Helm Dependencies
48+
run: |
49+
helm dependency build charts/network-operator
50+
- name: Package Helm Chart
51+
run: |
52+
helm package charts/network-operator --version ${{ steps.chart_version.outputs.version }}
53+
- name: Login to GitHub Container Registry
54+
if: github.event_name != 'pull_request'
55+
run: |
56+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
57+
- name: Push Helm Chart to ghcr.io
58+
if: github.event_name != 'pull_request'
59+
run: |
60+
helm push network-operator-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts

0 commit comments

Comments
 (0)