Skip to content

Commit

Permalink
Replace cert, server and token with a single input
Browse files Browse the repository at this point in the history
kube_config input will be used now, it will contains a regular
kubeconfig file and all the required information will be extracted
from there
  • Loading branch information
erickgnavar committed Mar 12, 2024
1 parent 881b3b4 commit a89ef70
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.17

RUN apk --update add curl bash jq
RUN apk --update add curl bash jq yq

# Download kubectl binary
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ This action will run `kubectl` to update the given deployment container with a n

| Input | Required | Description |
|-----------------|----------|--------------------------------------------------------------------------------------------------------------------------|
| cert | yes | base64 encoded certificate |
| server | yes | server host |
| token | yes | authentication token |
| kube_config | yes | cluster kubeconfig file, encoded in base64 |
| namespace | yes | deployment's namespace to be updated |
| name | yes | deployment's name to be updated |
| image | yes | image name what will be used in the update, example: `org/repo:version` |
Expand All @@ -31,4 +29,16 @@ This action will run `kubectl` to update the given deployment container with a n
external_secret: app-external-secret
```
```yaml
- name: Update deployment container image
uses: resuelve/deploy-to-kubernetes-action@v2
with:
kube_config: ${{ secrets.KUBERNETES_KUBE_CONFIG }}
namespace: default
name: my_project
image: new_image_name
container: backend
external_secret: app-external-secret
```
Enjoy 🎉
11 changes: 3 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
---
name: "Update kubernetes deployment image"
description: "Update kubernetes deployment image"
inputs:
cert:
description: "k8s cluster certificate"
required: true
server:
description: "k8s cluster server"
required: true
token:
description: "k8s cluster token"
kube_config:
description: "Kube config, regular kubeconfig file enccoded in base64"
required: true
namespace:
description: "Namespace where deployment is located"
Expand Down
8 changes: 5 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
# exit on any error
set -e

KUBERNETES_CERT="${INPUT_CERT}"
KUBERNETES_SERVER="${INPUT_SERVER}"
KUBERNETES_TOKEN="${INPUT_TOKEN}"
KUBERNETES_USER="default"
CONTEXT="default"
CLUSTER_NAME="default"
Expand All @@ -13,6 +10,11 @@ DEPLOYMENT="${INPUT_NAME}"
IMAGE="${INPUT_IMAGE}"
CONTAINER="${INPUT_CONTAINER}"
EXTERNAL_SECRET="${INPUT_EXTERNAL_SECRET}"
KUBE_CONFIG="${INPUT_KUBE_CONFIG}"

KUBERNETES_CERT=$(echo "$KUBE_CONFIG" | base64 -d | yq .clusters.0.cluster.certificate-authority-data)
KUBERNETES_SERVER=$(echo "$KUBE_CONFIG" | base64 -d | yq .clusters.0.cluster.server)
KUBERNETES_TOKEN=$(echo "$KUBE_CONFIG" | base64 -d | yq .users.0.user.token)

echo "${KUBERNETES_CERT}" | base64 -d >ca.crt

Expand Down

0 comments on commit a89ef70

Please sign in to comment.