Skip to content

Commit ed10f5f

Browse files
authored
Add Helm delete deployment action (#10)
* add Helm delete deployment action * fix docs formatting * rename Helm delete action to Helm undeploy
1 parent 03ee5ca commit ed10f5f

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

helm-undeploy/action.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Helm Undeploy"
2+
description: "Undeploy a Helm deployment from a Kubernetes cluster"
3+
4+
inputs:
5+
namespace:
6+
description: "The namespace of the Helm release"
7+
required: true
8+
release-name:
9+
description: "The name of the Helm release"
10+
required: true
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Delete Helm deployment
16+
env:
17+
HELM_DRIVER: configmaps
18+
run: |
19+
RELEASE_NAME="${{ inputs.release-name }}"
20+
NAMESPACE="${{ inputs.namespace }}"
21+
22+
echo "Checking Helm release: $RELEASE_NAME in namespace: $NAMESPACE"
23+
24+
STATUS_OUTPUT=$(helm status "$RELEASE_NAME" --namespace "$NAMESPACE" 2>&1) && STATUS_EXIT=0 || STATUS_EXIT=$?
25+
26+
if [ $STATUS_EXIT -eq 0 ]; then
27+
echo "Release found. Uninstalling..."
28+
helm uninstall "$RELEASE_NAME" --namespace "$NAMESPACE"
29+
else
30+
if echo "$STATUS_OUTPUT" | grep -qi "forbidden\|cannot list\|unauthorized\|permission"; then
31+
echo "::error::Permission denied when querying release '$RELEASE_NAME'. Check kubeconfig and RBAC permissions."
32+
echo "$STATUS_OUTPUT"
33+
exit 1
34+
else
35+
echo "Release '$RELEASE_NAME' not found, skipping uninstall."
36+
echo "$STATUS_OUTPUT"
37+
fi
38+
fi
39+
shell: bash

readme.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,28 @@ The following inputs can be used as `step.with` keys:
9090
| `timeout` | `5m` | The timeout for the Helm command |
9191
| `working-directory` | `.` | The working directory where the action commands will operate |
9292

93+
### Helm Undeploy
94+
95+
Undeploy a Helm deployment from a Kubernetes cluster. Checks if the release exists before attempting uninstall and detects permission errors. Requires Kubernetes to be configured first.
96+
97+
#### Example
98+
99+
```yaml
100+
- uses: aboutbits/github-actions-kubernetes/helm-undeploy@v4
101+
with:
102+
release-name: my-app
103+
namespace: my-namespace
104+
```
105+
106+
#### Inputs
107+
108+
The following inputs can be used as `step.with` keys:
109+
110+
| Name | Required/Default | Description |
111+
|----------------|------------------|--------------------------------|
112+
| `namespace` | required | The namespace of the Helm release |
113+
| `release-name` | required | The name of the Helm release |
114+
93115
### Setup S3 Preview
94116

95117
Creates an S3 preview prefix by copying from the main prefix.

0 commit comments

Comments
 (0)