Merge pull request #119 from amazeeio/gpt-pricing #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |