1+ name : Package and Publish Helm Charts
2+
3+ on :
4+ push :
5+ branches : [ main, dev ]
6+ paths :
7+ - ' helm/**'
8+ - ' .github/workflows/helm-package-publish.yml'
9+ pull_request :
10+ branches : [ main, dev ]
11+ paths :
12+ - ' helm/**'
13+ - ' .github/workflows/helm-package-publish.yml'
14+ release :
15+ types : [ published ]
16+
17+ env :
18+ REGISTRY : ghcr.io
19+ IMAGE_NAME : ${{ github.repository }}
20+
21+ jobs :
22+ package-and-publish :
23+ runs-on : ubuntu-latest
24+ permissions :
25+ contents : read
26+ packages : write
27+ security-events : write
28+
29+ steps :
30+ - name : Checkout code
31+ uses : actions/checkout@v4
32+ with :
33+ fetch-depth : 0
34+
35+ - name : Set up Helm
36+ uses : azure/setup-helm@v3
37+ with :
38+ version : v3.18.0
39+
40+ - name : Configure Git
41+ run : |
42+ git config user.name "github-actions[bot]"
43+ git config user.email "github-actions[bot]@users.noreply.github.com"
44+
45+ - name : Log in to Container Registry
46+ uses : docker/login-action@v3
47+ with :
48+ registry : ${{ env.REGISTRY }}
49+ username : ${{ github.actor }}
50+ password : ${{ secrets.GITHUB_TOKEN }}
51+
52+ - name : Package and publish subcharts
53+ run : |
54+ cd helm/charts
55+ for chart in */; do
56+ chart_name=$(basename "$chart")
57+ echo "Processing chart: $chart_name"
58+
59+ # Get chart version
60+ version=$(grep '^version:' "$chart_name/Chart.yaml" | awk '{print $2}')
61+ echo "Chart version: $version"
62+
63+ # Package the chart
64+ helm package "$chart_name"
65+
66+ # Push to OCI registry with version tag
67+ helm push "$chart_name-$version.tgz" oci://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
68+
69+ # Also push with latest tag by copying the chart and updating its version
70+ cp "$chart_name-$version.tgz" "$chart_name-latest.tgz"
71+ helm push "$chart_name-latest.tgz" oci://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
72+
73+ echo "✅ Published $chart_name:$version to GHCR via OCI"
74+ done
75+
76+ - name : Package and publish main chart
77+ run : |
78+ cd helm
79+
80+ # Update dependencies
81+ helm dependency update
82+
83+ # Package the main chart
84+ helm package .
85+
86+ # Get chart version
87+ version=$(grep '^version:' Chart.yaml | awk '{print $2}')
88+ echo "Main chart version: $version"
89+
90+ # Push to OCI registry with version tag
91+ helm push "amazee-ai-$version.tgz" oci://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
92+
93+ # Also push with latest tag by copying the chart
94+ cp "amazee-ai-$version.tgz" "amazee-ai-latest.tgz"
95+ helm push "amazee-ai-latest.tgz" oci://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
96+
97+ echo "✅ Published amazee-ai:$version to GHCR via OCI"
98+
99+ - name : Create Release Tag
100+ if : github.event_name == 'release'
101+ run : |
102+ cd helm
103+ version=$(grep '^version:' Chart.yaml | awk '{print $2}')
104+ echo "Creating release tag: v$version"
105+ git tag -a "v$version" -m "Release Helm charts version $version"
106+ git push origin "v$version"
107+
108+ test-charts :
109+ runs-on : ubuntu-latest
110+ permissions :
111+ contents : read
112+
113+ steps :
114+ - name : Checkout code
115+ uses : actions/checkout@v4
116+
117+ - name : Set up Helm
118+ uses : azure/setup-helm@v3
119+ with :
120+ version : v3.18.0
121+
122+ - name : Install kubectl
123+ uses : azure/setup-kubectl@v3
124+ with :
125+ version : ' latest'
126+
127+ - name : Test chart templates
128+ run : |
129+ # Test the main chart with minimal values
130+ cd helm
131+ helm dependency update
132+ helm template amazee-ai . --set frontend.enabled=false --set backend.enabled=false --set postgresql.enabled=false > /dev/null
133+ echo "✅ Main chart template test passed"
134+
135+ # Test individual subcharts
136+ cd charts
137+ for chart in */; do
138+ chart_name=$(basename "$chart")
139+ echo "Testing chart: $chart_name"
140+ helm template test-$chart_name "$chart_name" > /dev/null
141+ echo "✅ $chart_name chart template test passed"
142+ done
143+
144+ - name : Lint charts
145+ run : |
146+ cd helm
147+ helm lint . --strict
148+ cd charts
149+ for chart in */; do
150+ chart_name=$(basename "$chart")
151+ echo "Linting chart: $chart_name"
152+ helm lint "$chart_name" --strict
153+ done
0 commit comments