From ce66013aedb556579e30a6ccd073183c15d6ca7b Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Fri, 28 Feb 2025 16:03:44 +0100 Subject: [PATCH 1/5] add optional helm version input to action configuration --- do-setup-kubectl/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/do-setup-kubectl/action.yml b/do-setup-kubectl/action.yml index fa014c5..5f4c938 100644 --- a/do-setup-kubectl/action.yml +++ b/do-setup-kubectl/action.yml @@ -8,6 +8,11 @@ inputs: cluster-name: description: 'Kubernetes cluster name' required: true + helm-version: + description: 'Helm version to install' + required: false + default: '3.17.1' + runs: using: "composite" @@ -23,3 +28,5 @@ runs: - name: Setup Helm uses: azure/setup-helm@v4.2.0 + with: + version: ${{ inputs.helm-version }} From 87add6f275bf2972e3f9f97c0f3531b941839150 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Fri, 28 Feb 2025 16:03:52 +0100 Subject: [PATCH 2/5] add helm chart authentication, versioning, and deployment steps --- helm-deploy/action.yml | 70 +++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/helm-deploy/action.yml b/helm-deploy/action.yml index a80afc5..a92e2f5 100644 --- a/helm-deploy/action.yml +++ b/helm-deploy/action.yml @@ -1,34 +1,76 @@ -name: 'Deploy Helm chart to Kubernetes' -description: 'Deploy an application to a Kubernetes cluster using its Helm chart' +name: "Helm Chart Setup and Deployment" +description: "Setup a Helm chart, modify its appVersion, and deploy it to a Kubernetes cluster" inputs: + helm-chart-version: + description: "The Helm chart version to pull" + required: true + helm-registry-url: + description: "The Helm OCI registry URL" + default: "ghcr.io" + helm-package: + description: "The Helm package to pull" + required: true + helm-username: + description: "The username to authenticate with the Helm registry" + required: true + helm-password: + description: "The password to authenticate with the Helm registry" + required: true + helm-protocol: + description: "The protocol for fetching the Helm chart (e.g., oci://). Default is 'oci://'." + default: "oci://" release-name: - description: 'The name of the Helm release' + description: "The name of the Helm release" required: true - chart-path: - description: 'The directory of the Helm chart' - default: '.' values-file: - description: 'Path to the Helm values file' + description: "Path to the Helm values file" required: true image-tag: - description: 'Tag of the container image' - default: 'latest' + description: "Tag of the container image" + default: "latest" timeout: - description: 'Timeout for the Helm command' - default: '5m' + description: "Timeout for the Helm command" + default: "5m" working-directory: - description: 'The working directory' - default: '.' + description: "The working directory" + default: "." runs: using: "composite" steps: + - name: Login to Helm registry + shell: bash + run: | + helm registry login ${{ inputs.helm-registry-url }} \ + -u ${{ inputs.helm-username }} \ + -p ${{ inputs.helm-password }} + + - name: Pull the Helm chart + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + helm pull ${{ inputs.helm-protocol }}${{ inputs.helm-registry-url }}/${{ inputs.helm-package }} \ + --version ${{ inputs.helm-chart-version }} + + - name: Extract Helm chart + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + tar -xzf ${{ inputs.helm-package }}-*.tgz + + - name: Update appVersion in Chart.yaml + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + yq -i '.appVersion = "${{ github.sha }}" | .appVersion style="double"' \ + ${{ inputs.helm-package }}/Chart.yaml + - name: Deploy Helm chart shell: bash working-directory: ${{ inputs.working-directory }} run: | - helm upgrade --wait --install ${{ inputs.release-name }} ${{ inputs.chart-path }} \ + helm upgrade --wait --install ${{ inputs.release-name }} ./${{ inputs.helm-package }} \ --values ${{ inputs.values-file }} \ --atomic --timeout ${{ inputs.timeout }} \ --set image.tag=${{ inputs.image-tag }} From 8285c426c2acaa1f9e928112552f59ec5d416de7 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Fri, 28 Feb 2025 16:11:48 +0100 Subject: [PATCH 3/5] update readme to include helm inputs and usage examples --- readme.md | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/readme.md b/readme.md index 276a69a..4cdebee 100644 --- a/readme.md +++ b/readme.md @@ -21,10 +21,11 @@ Setup Digital-Ocean CLI and configure Kubernetes. The following inputs can be used as `step.with` keys: -| Name | Required/Default | Description | -|--------------------------|--------------------|---------------------------------| -| `digital-ocean-token` | required | Digital Ocean access token | -| `cluster-name` | required | Kubernetes cluster name | +| Name | Required/Default | Description | +|-----------------------|------------------|----------------------------------------| +| `digital-ocean-token` | required | DigitalOcean access token | +| `cluster-name` | required | Kubernetes cluster name | +| `helm-version` | `3.17.1` | The version of Helm to install and use | ### Deploy to Kubernetes using kubectl @@ -54,17 +55,20 @@ The following inputs can be used as `step.with` keys: ### Deploy to Kubernetes using Helm -Deploy an application to a Kubernetes cluster using its Helm diagram. Requires Kubernetes to be configured first. +Deploy an application to a Kubernetes cluster using its Helm chart. Requires Kubernetes to be configured first. #### Example ```yaml - uses: aboutbits/github-actions-kubernetes/helm-deploy@v2 with: + helm-chart-version: "1.0.0" + helm-package: "my-app-chart" + helm-username: ${{ secrets.HELM_USERNAME }} + helm-password: ${{ secrets.HELM_PASSWORD }} release-name: my-app - chart-directory: my-chart - image-tag: "1.0.0" values-file: environments/values-test.yaml + image-tag: "1.0.42" timeout: 5m working-directory: ./infrastructure ``` @@ -73,14 +77,19 @@ Deploy an application to a Kubernetes cluster using its Helm diagram. Requires K The following inputs can be used as `step.with` keys: -| Name | Required/Default | Description | -|---------------------|------------------|------------------------------------| -| `release-name` | required | The name of the Helm release | -| `values-file` | required | Path to the Helm values file | -| `working-directory` | `.` | The working directory | -| `chart-directory` | `.` | Root directory of the helm diagram | -| `image-tag` | `latest` | Tag of the container image | -| `timeout` | `5m` | Timeout for the Helm command | +| Name | Required/Default | Description | +|----------------------|------------------|--------------------------------------------------------------| +| `helm-chart-version` | required | The version of the Helm chart to pull | +| `helm-registry-url` | `ghcr.io` | The URL of the Helm OCI registry | +| `helm-package` | required | The name of the Helm package to pull | +| `helm-username` | required | The username for authenticating with the Helm registry | +| `helm-password` | required | The password for authenticating with the Helm registry | +| `helm-protocol` | `oci://` | The protocol for pulling Helm charts (e.g., `oci://`) | +| `release-name` | required | The name of the Helm release | +| `values-file` | required | Path to the Helm values file for customization | +| `image-tag` | `latest` | The tag of the container image to set | +| `timeout` | `5m` | The timeout for the Helm command | +| `working-directory` | `.` | The working directory where the action commands will operate | ## Versioning From d6a1aafd33b21ac4aae8c1a03a59230078aa0f50 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Mon, 3 Mar 2025 08:52:05 +0100 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Alex Lanz --- do-setup-kubectl/action.yml | 2 +- helm-deploy/action.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/do-setup-kubectl/action.yml b/do-setup-kubectl/action.yml index 5f4c938..49c1c48 100644 --- a/do-setup-kubectl/action.yml +++ b/do-setup-kubectl/action.yml @@ -9,7 +9,7 @@ inputs: description: 'Kubernetes cluster name' required: true helm-version: - description: 'Helm version to install' + description: 'Helm version' required: false default: '3.17.1' diff --git a/helm-deploy/action.yml b/helm-deploy/action.yml index a92e2f5..e9f4526 100644 --- a/helm-deploy/action.yml +++ b/helm-deploy/action.yml @@ -3,13 +3,13 @@ description: "Setup a Helm chart, modify its appVersion, and deploy it to a Kube inputs: helm-chart-version: - description: "The Helm chart version to pull" + description: "The Helm chart version" required: true helm-registry-url: description: "The Helm OCI registry URL" default: "ghcr.io" helm-package: - description: "The Helm package to pull" + description: "The Helm package" required: true helm-username: description: "The username to authenticate with the Helm registry" From b23b68e74bd906945cd130ac52837670dbb177c9 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Wed, 5 Mar 2025 11:42:20 +0100 Subject: [PATCH 5/5] make helm-registry-url a required input --- helm-deploy/action.yml | 2 +- readme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/helm-deploy/action.yml b/helm-deploy/action.yml index a92e2f5..4d22b79 100644 --- a/helm-deploy/action.yml +++ b/helm-deploy/action.yml @@ -7,7 +7,7 @@ inputs: required: true helm-registry-url: description: "The Helm OCI registry URL" - default: "ghcr.io" + required: true helm-package: description: "The Helm package to pull" required: true diff --git a/readme.md b/readme.md index 4cdebee..134430b 100644 --- a/readme.md +++ b/readme.md @@ -80,7 +80,7 @@ The following inputs can be used as `step.with` keys: | Name | Required/Default | Description | |----------------------|------------------|--------------------------------------------------------------| | `helm-chart-version` | required | The version of the Helm chart to pull | -| `helm-registry-url` | `ghcr.io` | The URL of the Helm OCI registry | +| `helm-registry-url` | required | The URL of the Helm OCI registry | | `helm-package` | required | The name of the Helm package to pull | | `helm-username` | required | The username for authenticating with the Helm registry | | `helm-password` | required | The password for authenticating with the Helm registry |