From 0d3e37bfe00d191bef6a3eb9aada2e6a704597bd Mon Sep 17 00:00:00 2001 From: Skydust Date: Sat, 7 Dec 2024 15:44:48 +0100 Subject: [PATCH] Initial commit --- .gitignore | 1 + Dockerfile | 11 +++++++++++ action.yml | 13 +++++++++++++ entrypoint.sh | 20 ++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 action.yml create mode 100644 entrypoint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1b3813e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM public.ecr.aws/docker/library/node:22-alpine3.20 + +# Install git for gitea actions and ansible +RUN apk add --no-cache git kubectl bash + +WORKDIR /usr/src + +COPY entrypoint.sh . + +RUN chmod +x /usr/src/entrypoint.sh +ENTRYPOINT ["bash","-c","/usr/src/entrypoint.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..269c6a6 --- /dev/null +++ b/action.yml @@ -0,0 +1,13 @@ +name: Restart kube apps +description: Permits restarting a deployed kube-app when an update is pushed +author: Skydust + +# Define your inputs here. +inputs: + deploymentName: + description: The deployment name + required: true + +runs: + using: docker + image: Dockerfile diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..e17a68c --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +INPUT_DEPLOYMENT_NAME=$deploymentName + +set -e + +echo "Searching kubectl rights in env: KUBERNETES_BASE64_CONF" +if [[ -z "$KUBERNETES_BASE64_CONF" ]]; then + echo "No kubernetes config found." + echo "Encode it in base64 and place it in gitea secrets" +fi +echo "$KUBERNETES_BASE64_CONF" | base64 -d > "/root/.kube/config" + +KUBECTL_OPTIONS+=("rollout" "restart" "deployment/${INPUT_DEPLOYMENT_NAME}") + +# shellcheck disable=SC2145 +echo "Running kubectl with options: ${KUBECTL_OPTIONS[@]}" +kubectl ${KUBECTL_OPTIONS[@]} + +exit 0