From c74f774b84da60121c4a9f72f67bac481ce9699c Mon Sep 17 00:00:00 2001 From: Evan Johnson Date: Wed, 14 Feb 2024 12:01:27 -0500 Subject: [PATCH] add helm test and publish workflow --- .github/workflows/helm.yml | 85 ++++++++++++++++++++++++++++++++++++++ deploy/chart/Chart.yaml | 4 +- deploy/chart/values.yaml | 4 +- 3 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/helm.yml diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml new file mode 100644 index 00000000..d6aa1ed7 --- /dev/null +++ b/.github/workflows/helm.yml @@ -0,0 +1,85 @@ +name: Helm + +on: + push: + branches: + - main + paths: + - 'deploy/chart/**' + pull_request: + paths: + - 'deploy/chart/**' + workflow_dispatch: {} + +permissions: + contents: read + +jobs: + helm-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set Version + run: | + TAG=$(git describe --tags --abbrev=0) + sed -ie "s/appVersion: \"latest\"/appVersion: ${TAG}/g" deploy/chart/Chart.yaml + sed -ie "s/version: 0.0.0/version: ${TAG}/g" deploy/chart/Chart.yaml + + - name: Set up Helm + uses: azure/setup-helm@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.0 + + - name: Run chart-testing (lint) + run: ct lint --check-version-increment=false --chart-dirs deploy --target-branch ${{ github.event.repository.default_branch }} + + # we cannot test a helm install without a valid linode + # - name: Create kind cluster + # uses: helm/kind-action@v1.8.0 + + #- name: Run chart-testing (install) + # run: ct install --chart-dirs helm-chart --namespace kube-system --helm-extra-set-args "--set=apiToken=test --set=region=us-east" --target-branch ${{ github.event.repository.default_branch }} + + helm-release: + if: github.ref == 'refs/heads/main' + needs: helm-test + permissions: + contents: write # for helm/chart-releaser-action to push chart release and create a release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set Version + run: | + TAG=$(git describe --tags --abbrev=0) + sed -ie "s/appVersion: \"latest\"/appVersion: ${TAG}/g" deploy/chart/Chart.yaml + sed -ie "s/version: 0.0.0/version: ${TAG}/g" deploy/chart/Chart.yaml + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Set up Helm + uses: azure/setup-helm@v3 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + with: + charts_dir: deploy + skip_existing: true diff --git a/deploy/chart/Chart.yaml b/deploy/chart/Chart.yaml index c442b685..959afc24 100644 --- a/deploy/chart/Chart.yaml +++ b/deploy/chart/Chart.yaml @@ -2,5 +2,7 @@ apiVersion: v2 name: ccm-linode description: The Linode Cloud Controller Manager (CCM) provides a way for Kubernetes clusters to access additional Linode services. Linode's CCM will automatically provision a Linode NodeBalancer for Kubernetes Services of type "LoadBalancer". type: application -version: 1.0.0 +version: 0.0.0 appVersion: "latest" +maintainers: + - name: linode diff --git a/deploy/chart/values.yaml b/deploy/chart/values.yaml index 790458df..2c00b6d6 100644 --- a/deploy/chart/values.yaml +++ b/deploy/chart/values.yaml @@ -19,7 +19,7 @@ nodeSelector: # The pullPolicy is set to Always but can be changed when it is not required to always pull the new image image: repository: linode/linode-cloud-controller-manager - tag: latest + tag: # only set if required, defaults to .Chart.AppVersion set during release or "latest" by default pullPolicy: Always # Default namespace is "kube-system" but it can be set to another namespace @@ -48,4 +48,4 @@ tolerations: # LINODE_HOSTNAME_ONLY_INGRESS type bool is supported # env: # - name: EXAMPLE_ENV_VAR - # value: "true" \ No newline at end of file + # value: "true"