ci: Setup GitHub helm chart releases #28
Workflow file for this run
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 | |
| pull_request: | |
| paths: | |
| - 'deployment/kubernetes/charts/**' | |
| - '.github/workflows/kubernetes**' | |
| defaults: | |
| run: | |
| working-directory: ./deployment/kubernetes | |
| jobs: | |
| helm-lint-test: | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.user.login != 'dependabot[bot]' && github.repository == 'CogStack/cogstack-platform-toolkit' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4.3.0 | |
| with: | |
| version: v3.18.3 | |
| - uses: actions/setup-python@v5.3.0 | |
| with: | |
| python-version: '3.x' | |
| check-latest: true | |
| - name: Set up chart-testing | |
| uses: helm/chart-testing-action@v2.7.0 | |
| - 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_UTPUT" | |
| 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/kind-action@v1.12.0 | |
| - name: Run chart-testing (install) | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: ct install --target-branch ${{ github.event.repository.default_branch }} | |
| 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/setup-helm@v4.2.0 | |
| 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 chart- | |
| CHART_VERSION="${GITHUB_REF_NAME#helm-charts-}" | |
| else | |
| CHART_VERSION="$DEFAULT_CHART_VERSION" | |
| fi | |
| echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Package Helm Charts | |
| run: | | |
| helm package ./charts/medcat-service-helm --version ${{ steps.version.outputs.chart_version }} | |
| helm package ./charts/medcat-trainer-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-${CHART_VERSION}.tgz oci://registry-1.docker.io/cogstacksystems | |
| helm push ./medcat-trainer-helm-${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: | | |
| ./deployment/kubernetes/medcat-service-helm-${CHART_VERSION}.tgz | |
| ./deployment/kubernetes/medcat-trainer-helm-${CHART_VERSION}.tgz |