mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 03:20:11 +00:00
182 lines
6.1 KiB
YAML
182 lines
6.1 KiB
YAML
name: Release Helm Chart to GitHub Pages
|
|
run-name: Release Helm Chart ${{ inputs.chart_version }}
|
|
|
|
# Triggered by publish-docker.yml after image publication, or manually.
|
|
# The smoke test pulls the Docker image for the release tag.
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
chart_version:
|
|
description: "Chart version (e.g., 4.28.0)"
|
|
required: true
|
|
type: string
|
|
target_branch:
|
|
description: "Branch to update (defaults to release/5.1)"
|
|
required: false
|
|
default: "release/5.1"
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Resolve target branch
|
|
id: target_branch
|
|
run: |
|
|
TARGET_BRANCH="${{ inputs.target_branch }}"
|
|
if [ -z "$TARGET_BRANCH" ]; then
|
|
TARGET_BRANCH="release/5.1"
|
|
fi
|
|
|
|
if [ -z "$TARGET_BRANCH" ]; then
|
|
echo "::error::Could not determine target branch"
|
|
exit 1
|
|
fi
|
|
|
|
echo "branch=$TARGET_BRANCH" >> "$GITHUB_OUTPUT"
|
|
echo "Using target branch: $TARGET_BRANCH"
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ steps.target_branch.outputs.branch }}
|
|
|
|
- name: Ensure branch checkout
|
|
run: git checkout "${{ steps.target_branch.outputs.branch }}"
|
|
|
|
- name: Configure Git
|
|
run: |
|
|
git config user.name "$GITHUB_ACTOR"
|
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
|
|
|
- name: Install Helm
|
|
uses: azure/setup-helm@v4
|
|
with:
|
|
version: v3.15.2
|
|
|
|
- name: Install helm-docs
|
|
run: |
|
|
cd /tmp
|
|
wget https://github.com/norwoodj/helm-docs/releases/download/v1.14.2/helm-docs_1.14.2_Linux_x86_64.tar.gz
|
|
tar -xzf helm-docs_1.14.2_Linux_x86_64.tar.gz
|
|
sudo mv helm-docs /usr/local/bin/
|
|
helm-docs --version
|
|
|
|
- name: Generate chart documentation
|
|
env:
|
|
TARGET_BRANCH: ${{ steps.target_branch.outputs.branch }}
|
|
run: |
|
|
cd deploy/helm/pulse
|
|
helm-docs
|
|
|
|
# Commit if README changed
|
|
if ! git diff --quiet README.md; then
|
|
git config user.name "$GITHUB_ACTOR"
|
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
|
git add README.md
|
|
git commit -m "Auto-update Helm chart documentation"
|
|
git pull --rebase origin "$TARGET_BRANCH"
|
|
git push origin HEAD:"$TARGET_BRANCH"
|
|
fi
|
|
cd ../../..
|
|
|
|
- name: Resolve chart version
|
|
id: version
|
|
run: |
|
|
VERSION="${{ inputs.chart_version }}"
|
|
if [ -z "$VERSION" ]; then
|
|
echo "::error::chart_version input is required"
|
|
exit 1
|
|
fi
|
|
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
echo "Chart version: $VERSION"
|
|
|
|
- name: Update Chart.yaml version
|
|
env:
|
|
TARGET_BRANCH: ${{ steps.target_branch.outputs.branch }}
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
sed -i "s/^version: .*/version: $VERSION/" deploy/helm/pulse/Chart.yaml
|
|
sed -i "s/^appVersion: .*/appVersion: \"$VERSION\"/" deploy/helm/pulse/Chart.yaml
|
|
|
|
# Commit if Chart.yaml changed
|
|
if ! git diff --quiet deploy/helm/pulse/Chart.yaml; then
|
|
git config user.name "$GITHUB_ACTOR"
|
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
|
git add deploy/helm/pulse/Chart.yaml
|
|
git commit -m "Auto-update Helm chart version to $VERSION"
|
|
git pull --rebase origin "$TARGET_BRANCH"
|
|
git push origin HEAD:"$TARGET_BRANCH"
|
|
fi
|
|
|
|
- name: Validate Helm chart
|
|
run: |
|
|
# Strict linting
|
|
helm lint deploy/helm/pulse --strict
|
|
|
|
# Template validation with minimal values
|
|
helm template pulse deploy/helm/pulse --set persistence.enabled=false > /dev/null
|
|
|
|
# Template validation with common overrides
|
|
helm template pulse deploy/helm/pulse \
|
|
--set ingress.enabled=true \
|
|
--set ingress.hosts[0].host=pulse.example.com \
|
|
--set agent.enabled=true > /dev/null
|
|
|
|
echo "✓ Chart validation passed"
|
|
|
|
- name: Smoke test with kind
|
|
run: |
|
|
# Install kind
|
|
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
|
|
chmod +x ./kind
|
|
sudo mv ./kind /usr/local/bin/kind
|
|
|
|
# Create cluster
|
|
kind create cluster --name pulse-test --wait 5m
|
|
|
|
# Install chart
|
|
helm install pulse deploy/helm/pulse \
|
|
--set persistence.enabled=false \
|
|
--set server.secretEnv.create=true \
|
|
--set server.secretEnv.data.API_TOKENS=test-token \
|
|
--wait --timeout 5m
|
|
|
|
# Verify deployment
|
|
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=pulse --timeout=180s || (kubectl describe pods -l app.kubernetes.io/name=pulse && exit 1)
|
|
kubectl get pods -l app.kubernetes.io/name=pulse
|
|
|
|
# Test upgrade
|
|
helm upgrade pulse deploy/helm/pulse \
|
|
--set persistence.enabled=false \
|
|
--set server.secretEnv.create=true \
|
|
--set server.secretEnv.data.API_TOKENS=test-token \
|
|
--wait --timeout 5m
|
|
|
|
# Cleanup
|
|
kind delete cluster --name pulse-test
|
|
|
|
echo "✓ Smoke test passed"
|
|
|
|
- name: Run chart-releaser
|
|
uses: helm/chart-releaser-action@v1.6.0
|
|
with:
|
|
charts_dir: deploy/helm
|
|
config: cr.yaml
|
|
skip_existing: true
|
|
env:
|
|
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
CR_RELEASE_NAME_TEMPLATE: "helm-chart-{{ .Version }}"
|
|
CR_MAKE_RELEASE_LATEST: false
|
|
|
|
- name: Mark Helm chart release as pre-release (avoid latest override)
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
run: |
|
|
TAG="helm-chart-${{ steps.version.outputs.version }}"
|
|
gh release edit "$TAG" --prerelease --latest=false || echo "No helm chart release to edit for $TAG"
|