Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions do-setup-kubectl/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ inputs:
cluster-name:
description: 'Kubernetes cluster name'
required: true
helm-version:
description: 'Helm version'
required: false
default: '3.17.1'


runs:
using: "composite"
Expand All @@ -23,3 +28,5 @@ runs:

- name: Setup Helm
uses: azure/setup-helm@v4.2.0
with:
version: ${{ inputs.helm-version }}
70 changes: 56 additions & 14 deletions helm-deploy/action.yml
Original file line number Diff line number Diff line change
@@ -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"
required: true
helm-registry-url:
description: "The Helm OCI registry URL"
required: true
helm-package:
description: "The Helm package"
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
Comment on lines +56 to +60

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, is this really a required step. 🤯

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need this step because we want to set the app version to the commit hash. If we didn't set this or left it at a fixed value, we could omit this and the pull step and specify the OCI image directly when upgrading. But as I said, without the app version it is relatively difficult to find the deployment again


- 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 }}
39 changes: 24 additions & 15 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
```
Expand All @@ -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` | 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 |
| `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

Expand Down