Add DashboardSpec validation tests and enhance configuration options #15
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: Helm Chart Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'charts/**' | |
| tags: | |
| - 'v*.*.*' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'charts/**' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| lint-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: v3.17.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Set up chart-testing | |
| uses: helm/[email protected] | |
| - name: Run chart-testing (list-changed) | |
| id: list-changed | |
| run: | | |
| changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) | |
| if [[ -n "$changed" ]]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Run chart-testing (lint) | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: ct lint --target-branch ${{ github.event.repository.default_branch }} | |
| - name: Create kind cluster | |
| if: steps.list-changed.outputs.changed == 'true' | |
| uses: helm/[email protected] | |
| - name: Run chart-testing (install) | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: ct install --target-branch ${{ github.event.repository.default_branch }} | |
| publish: | |
| needs: lint-test | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: v3.17.0 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| run: | | |
| # Extract base version from Chart.yaml | |
| BASE_CHART_VERSION=$(grep '^version:' charts/homer-operator/Chart.yaml | awk '{print $2}') | |
| APP_VERSION=$(grep '^appVersion:' charts/homer-operator/Chart.yaml | awk '{print $2}' | tr -d '"') | |
| # Determine version based on ref | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| # Tagged release - use tag version | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| CHART_VERSION=$TAG_VERSION | |
| echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT | |
| echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT | |
| echo "Using tag version: $TAG_VERSION" | |
| elif [[ $GITHUB_REF == refs/heads/main ]]; then | |
| # Main branch - use 0.0.0-latest | |
| CHART_VERSION="0.0.0-latest" | |
| echo "version=0.0.0-latest" >> $GITHUB_OUTPUT | |
| echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT | |
| echo "Using main branch version: 0.0.0-latest" | |
| else | |
| # Other branches - use branch-specific prerelease version | |
| BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
| BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]') | |
| CHART_VERSION="${BASE_CHART_VERSION}-${BRANCH_NAME}.${GITHUB_SHA::8}" | |
| echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT | |
| echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT | |
| echo "Using branch version: $CHART_VERSION" | |
| fi | |
| echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT | |
| echo "base_chart_version=$BASE_CHART_VERSION" >> $GITHUB_OUTPUT | |
| - name: Update Chart versions | |
| run: | | |
| CHART_VERSION="${{ steps.meta.outputs.chart_version }}" | |
| # Update chart version | |
| sed -i "s/version: .*/version: $CHART_VERSION/" charts/homer-operator/Chart.yaml | |
| # Update appVersion based on context | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| # For tagged releases, use the tag version | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| sed -i "s/appVersion: .*/appVersion: \"$TAG_VERSION\"/" charts/homer-operator/Chart.yaml | |
| echo "Updated appVersion to: $TAG_VERSION" | |
| elif [[ $GITHUB_REF == refs/heads/main ]]; then | |
| # For main branch, use latest | |
| sed -i "s/appVersion: .*/appVersion: \"latest\"/" charts/homer-operator/Chart.yaml | |
| echo "Updated appVersion to: latest" | |
| else | |
| # For other branches, keep current appVersion but could use branch-specific if needed | |
| echo "Keeping current appVersion for branch build" | |
| fi | |
| echo "Updated chart version to: $CHART_VERSION" | |
| - name: Package and Push Helm Chart | |
| run: | | |
| CHART_VERSION="${{ steps.meta.outputs.chart_version }}" | |
| REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
| # Package the chart | |
| helm package charts/homer-operator --destination ./packaged-charts | |
| # Push to GHCR | |
| helm push "./packaged-charts/homer-operator-${CHART_VERSION}.tgz" "oci://${{ env.REGISTRY }}/${REPO_NAME}/charts" | |
| echo "Chart pushed to: oci://${{ env.REGISTRY }}/${REPO_NAME}/charts/homer-operator:${CHART_VERSION}" | |
| - name: Generate chart summary | |
| run: | | |
| CHART_VERSION="${{ steps.meta.outputs.chart_version }}" | |
| REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
| echo "## Helm Chart Published 🚀" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Chart Version:** \`$CHART_VERSION\`" >> $GITHUB_STEP_SUMMARY | |
| echo "**Registry:** \`${{ env.REGISTRY }}/${REPO_NAME}/charts\`" >> $GITHUB_STEP_SUMMARY | |
| echo "**Branch/Tag:** \`${GITHUB_REF#refs/heads/}${GITHUB_REF#refs/tags/}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [[ $GITHUB_REF == refs/heads/main ]]; then | |
| echo "### Installation (Latest Development)" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | |
| echo "# Install latest development version from main branch" >> $GITHUB_STEP_SUMMARY | |
| echo "helm install homer-operator oci://${{ env.REGISTRY }}/${REPO_NAME}/charts/homer-operator --version $CHART_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "⚠️ **Note:** This is a development build from the main branch. For production use, please use a tagged release." >> $GITHUB_STEP_SUMMARY | |
| elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
| echo "### Installation (Stable Release)" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | |
| echo "# Install stable release" >> $GITHUB_STEP_SUMMARY | |
| echo "helm install homer-operator oci://${{ env.REGISTRY }}/${REPO_NAME}/charts/homer-operator --version $CHART_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ **This is a stable release suitable for production use.**" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "### Installation (Branch Build)" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | |
| echo "# Install branch-specific build" >> $GITHUB_STEP_SUMMARY | |
| echo "helm install homer-operator oci://${{ env.REGISTRY }}/${REPO_NAME}/charts/homer-operator --version $CHART_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "🔬 **This is a branch build for testing purposes only.**" >> $GITHUB_STEP_SUMMARY | |
| fi |