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