chore: Rename 'Cogstack Helm CE' to 'Cogstack CE Helm' to be consiste… #148
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: Kubernetes - Lint, Test, and Publish Helm Charts | |
| on: | |
| push: | |
| branches: [main] | |
| tags: | |
| - "helm-charts-v*.*.*" # e.g., helm-charts-v0.1.1 | |
| paths: | |
| - "helm-charts/**" | |
| - ".github/workflows/kubernetes-charts-build**" | |
| pull_request: | |
| paths: | |
| - "helm-charts/**" | |
| - ".github/workflows/kubernetes**" | |
| defaults: | |
| run: | |
| working-directory: ./helm-charts | |
| jobs: | |
| helm-lint-test: | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.user.login != 'dependabot[bot]' && github.repository == 'CogStack/cogstack-platform' | |
| steps: | |
| - name: Checkout | |
| uses: actions/[email protected] | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/[email protected] | |
| - uses: actions/[email protected] | |
| with: | |
| python-version: "3.x" | |
| check-latest: true | |
| - name: Set up chart-testing | |
| uses: helm/[email protected] | |
| - name: Run chart-testing (list-changed) | |
| id: list-changed | |
| working-directory: . | |
| run: | | |
| changed=$(ct list-changed --config .github/linters/ct.yaml) | |
| if [[ -n "$changed" ]]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Recursive dependency update (all charts, including nested) | |
| run: | | |
| # Run twice so nested subcharts (like cogstack-jupyterhub -> jupyterhub) are fully updated | |
| for _ in 1 2; do | |
| # Find every Chart.yaml under helm-charts and run helm dependency update in its directory | |
| while IFS= read -r chartfile; do | |
| chart_dir="$(dirname "$chartfile")" | |
| if grep -q "^dependencies:" "$chartfile" 2>/dev/null; then | |
| echo "Updating dependencies for $chart_dir" | |
| helm dependency update "$chart_dir" | |
| fi | |
| done < <(find . -type f -name Chart.yaml) | |
| done | |
| - name: Run chart-testing (lint) | |
| if: steps.list-changed.outputs.changed == 'true' | |
| working-directory: . | |
| env: | |
| CT_CHECK_VERSION_INCREMENT: "false" | |
| run: ct lint --config .github/linters/ct.yaml | |
| - 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' | |
| working-directory: . | |
| run: ct install --config .github/linters/ct.yaml | |
| helm-publish: | |
| runs-on: ubuntu-latest | |
| needs: helm-lint-test | |
| permissions: | |
| contents: write | |
| env: | |
| DEFAULT_CHART_VERSION: 0.0.1 | |
| steps: | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Helm | |
| uses: azure/[email protected] | |
| with: | |
| version: v3.17.0 | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | |
| # Strip the tag prefix helm-charts-v | |
| CHART_VERSION="${GITHUB_REF_NAME#helm-charts-v}" | |
| else | |
| CHART_VERSION="$DEFAULT_CHART_VERSION" | |
| fi | |
| echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Recursive dependency update (all charts, including nested) | |
| # Waiting on helm recursive feature https://github.com/helm/helm/pull/30855 | |
| # Could alternatively switch to helm "cascade" plugin | |
| run: | | |
| # Run twice so nested subcharts (like cogstack-jupyterhub -> jupyterhub) are fully updated | |
| for _ in 1 2; do | |
| # Find every Chart.yaml under helm-charts and run helm dependency update in its directory | |
| while IFS= read -r chartfile; do | |
| chart_dir="$(dirname "$chartfile")" | |
| if grep -q "^dependencies:" "$chartfile" 2>/dev/null; then | |
| echo "Updating dependencies for $chart_dir" | |
| helm dependency update "$chart_dir" | |
| fi | |
| done < <(find . -type f -name Chart.yaml) | |
| done | |
| - name: Package Helm Charts | |
| run: | | |
| helm package ./medcat-service-helm --version ${{ steps.version.outputs.chart_version }} | |
| helm package ./medcat-trainer-helm --version ${{ steps.version.outputs.chart_version }} --dependency-update | |
| helm package ./cogstack-ce-helm --version ${{ steps.version.outputs.chart_version }} --dependency-update | |
| - name: Helm OCI login to Docker Hub | |
| run: helm registry login registry-1.docker.io -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Push Helm Chart to Docker Hub OCI | |
| run: | | |
| helm push ./medcat-service-helm-${{ steps.version.outputs.chart_version }}.tgz oci://registry-1.docker.io/cogstacksystems | |
| helm push ./medcat-trainer-helm-${{ steps.version.outputs.chart_version }}.tgz oci://registry-1.docker.io/cogstacksystems | |
| helm push ./cogstack-ce-helm-${{ steps.version.outputs.chart_version }}.tgz oci://registry-1.docker.io/cogstacksystems | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| if: github.ref_type == 'tag' | |
| with: | |
| draft: true | |
| files: | | |
| helm-charts/*.tgz |