From af00e434d9d20a1be65b818168155f85c434553b Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 11:00:10 +0100 Subject: [PATCH 01/12] setup helm as part of the overall setup --- do-setup-kubectl/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/do-setup-kubectl/action.yml b/do-setup-kubectl/action.yml index c61e3d0..529ffdd 100644 --- a/do-setup-kubectl/action.yml +++ b/do-setup-kubectl/action.yml @@ -20,3 +20,8 @@ runs: - name: Save DigitalOcean kubeconfig with short-lived credentials run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ inputs.cluster-name }} shell: bash + + - name: Setup helm + uses: azure/setup-helm@v4.2.0 + with: + version: 'v3.13.3' From 08276698dc074e8a538a7cf11387153d30ea9f2d Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 11:00:28 +0100 Subject: [PATCH 02/12] add action to deploy app using helm --- deploy-helm/action.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 deploy-helm/action.yml diff --git a/deploy-helm/action.yml b/deploy-helm/action.yml new file mode 100644 index 0000000..c78f09b --- /dev/null +++ b/deploy-helm/action.yml @@ -0,0 +1,38 @@ +name: 'Deploy Helm chart to Kubernetes' +description: 'Deploy an application to a Kubernetes cluster using its Helm chart' + +inputs: + release-name: + description: 'The name of the Helm release' + required: true + chart-path: + description: 'Path to the Helm chart' + required: true + values-file: + description: 'Path to the Helm values file' + required: true + image-tag: + description: 'Tag of the container image' + required: false + default: 'latest' + timeout: + description: 'Timeout for the Helm command' + required: false + default: '5m' + working-directory: + description: 'The working directory' + required: false + default: '.' + +runs: + using: "composite" + steps: + - name: Deploy Helm Chart + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + helm upgrade --install ${{ inputs.release-name }} ${{ inputs.chart-path }} \ + --values ${{ inputs.values-file }} \ + --atomic --timeout ${{ inputs.timeout }} \ + --set appVersion=${GITHUB_SHA:0:7} \ + --set image.tag=${{ inputs.image-tag }} From 91f1d9fbced74c3dc0d92af4a1e5c1b423822634 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 11:02:26 +0100 Subject: [PATCH 03/12] use latest for azure/setup-helm --- do-setup-kubectl/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/do-setup-kubectl/action.yml b/do-setup-kubectl/action.yml index 529ffdd..b08a323 100644 --- a/do-setup-kubectl/action.yml +++ b/do-setup-kubectl/action.yml @@ -23,5 +23,3 @@ runs: - name: Setup helm uses: azure/setup-helm@v4.2.0 - with: - version: 'v3.13.3' From e4f9ff5c2013f95ceb07981367e04bd6e710d866 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 11:11:17 +0100 Subject: [PATCH 04/12] add docs --- readme.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/readme.md b/readme.md index 8f3d90f..c6695db 100644 --- a/readme.md +++ b/readme.md @@ -52,6 +52,35 @@ The following inputs can be used as `step.with` keys: | `deployment-name` | required | Kubernetes deployment name | | `working-directory` | `.` | The working directory | +### Deploy to Kubernetes using Helm + +Deploy an application to a Kubernetes cluster using its Helm diagram. Requires Kubernetes to be configured first. + +#### Example + +```yaml + - uses: ./.github/actions/helm-deploy + with: + release-name: my-app + chart-path: my-chart + image-tag: "1.0.0" + values-file: environments/values-test.yaml + timeout: 5m + working-directory: ./infrastructure +``` + +#### Inputs + +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-path` | `.` | Path to the Helm chart | +| `image-tag` | `latest` | Tag of the container image | +| `timeout` | `5m` | Timeout for the Helm command | ## Versioning From c192ec361f47c6457ad6921830c98f9abf8cc912 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 11:11:25 +0100 Subject: [PATCH 05/12] cleanup action --- deploy-helm/action.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/deploy-helm/action.yml b/deploy-helm/action.yml index c78f09b..94e76fa 100644 --- a/deploy-helm/action.yml +++ b/deploy-helm/action.yml @@ -7,21 +7,18 @@ inputs: required: true chart-path: description: 'Path to the Helm chart' - required: true + default: '.' values-file: description: 'Path to the Helm values file' required: true image-tag: description: 'Tag of the container image' - required: false default: 'latest' timeout: description: 'Timeout for the Helm command' - required: false default: '5m' working-directory: description: 'The working directory' - required: false default: '.' runs: From d9e298af335c7a9fb12d42530b583ef308b7f190 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 11:20:50 +0100 Subject: [PATCH 06/12] add --wait flag --- deploy-helm/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deploy-helm/action.yml b/deploy-helm/action.yml index 94e76fa..d0e4017 100644 --- a/deploy-helm/action.yml +++ b/deploy-helm/action.yml @@ -28,8 +28,7 @@ runs: shell: bash working-directory: ${{ inputs.working-directory }} run: | - helm upgrade --install ${{ inputs.release-name }} ${{ inputs.chart-path }} \ + helm upgrade --wait --install ${{ inputs.release-name }} ${{ inputs.chart-path }} \ --values ${{ inputs.values-file }} \ --atomic --timeout ${{ inputs.timeout }} \ - --set appVersion=${GITHUB_SHA:0:7} \ --set image.tag=${{ inputs.image-tag }} From d6ca34279b85ee35b4279c98b25f617e4ad0c7c0 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 14:10:41 +0100 Subject: [PATCH 07/12] rename to helm-deploy --- {deploy-helm => helm-deploy}/action.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {deploy-helm => helm-deploy}/action.yml (100%) diff --git a/deploy-helm/action.yml b/helm-deploy/action.yml similarity index 100% rename from deploy-helm/action.yml rename to helm-deploy/action.yml From 9f49122484369d7b726ec67adf34e2d3e1e8c798 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 14:10:45 +0100 Subject: [PATCH 08/12] rename to kubectl-deploy --- {deploy => kubectl-deploy}/action.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {deploy => kubectl-deploy}/action.yml (100%) diff --git a/deploy/action.yml b/kubectl-deploy/action.yml similarity index 100% rename from deploy/action.yml rename to kubectl-deploy/action.yml From dc19b57aa6314cebf5599ace41f52fa655bb8684 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 14:10:56 +0100 Subject: [PATCH 09/12] adjust docs --- readme.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index c6695db..6677ac8 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ Setup Digital-Ocean CLI and configure Kubernetes. #### Example ```yaml - - uses: aboutbits/github-actions-kubernetes/do-setup-kubectl@v1 + - uses: aboutbits/github-actions-kubernetes/do-setup-kubectl@v2 with: digital-ocean-token: ${{ secrets.DIGITALOCEAN_TOKEN }} cluster-name: ${{ env.CLUSTER_NAME }} @@ -34,7 +34,7 @@ Deploy application to a Kubernetes Cluster. Requires Kubernetes to be configured #### Example ```yaml - - uses: aboutbits/github-actions-kubernetes/deploy@v1 + - uses: aboutbits/github-actions-kubernetes/kubectl-deploy@v2 with: deployment-file: 'infrastructure/kubernetes.prod.yml' namespace-name: ${{ env.NAMESPACE_NAME }} @@ -59,10 +59,10 @@ Deploy an application to a Kubernetes cluster using its Helm diagram. Requires K #### Example ```yaml - - uses: ./.github/actions/helm-deploy + - uses: aboutbits/github-actions-kubernetes/helm-deploy@v2 with: release-name: my-app - chart-path: my-chart + chart-directory: my-chart image-tag: "1.0.0" values-file: environments/values-test.yaml timeout: 5m @@ -73,14 +73,14 @@ 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-path` | `.` | Path to the Helm chart | -| `image-tag` | `latest` | Tag of the container image | -| `timeout` | `5m` | Timeout for the Helm command | +| 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 | ## Versioning From 81f520b5d4946e73d222b8f0284b9613fa7f9461 Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 14:20:43 +0100 Subject: [PATCH 10/12] adjust readme to reflect new versions --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 6677ac8..dcfefaf 100644 --- a/readme.md +++ b/readme.md @@ -89,16 +89,16 @@ In order to have a versioning in place and working, create lightweight tags that Creating a new minor release: ```bash -git tag v1 +git tag v2 git push --tags ``` Replacing an already existing minor release: ```bash -git tag -d v1 -git push origin :refs/tags/v1 -git tag v1 +git tag -d v2 +git push origin :refs/tags/v2 +git tag v2 git push --tags ``` From 20c8091ff48705d3fe7fe6b0679125d70fa1fabf Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 14:20:50 +0100 Subject: [PATCH 11/12] fix typo in description --- helm-deploy/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-deploy/action.yml b/helm-deploy/action.yml index d0e4017..5bbbd1a 100644 --- a/helm-deploy/action.yml +++ b/helm-deploy/action.yml @@ -6,7 +6,7 @@ inputs: description: 'The name of the Helm release' required: true chart-path: - description: 'Path to the Helm chart' + description: 'The directory of the Helm chart' default: '.' values-file: description: 'Path to the Helm values file' From 55f1434e2d87d4858055f956f3e61fb60fd7434e Mon Sep 17 00:00:00 2001 From: Simon Planinschek Date: Thu, 23 Jan 2025 14:21:49 +0100 Subject: [PATCH 12/12] adjust type for deploy with kubectl --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index dcfefaf..276a69a 100644 --- a/readme.md +++ b/readme.md @@ -27,7 +27,7 @@ The following inputs can be used as `step.with` keys: | `cluster-name` | required | Kubernetes cluster name | -### Deploy to Kubernetes +### Deploy to Kubernetes using kubectl Deploy application to a Kubernetes Cluster. Requires Kubernetes to be configured first.