commit ea50afcd5cc355fdcc8b979e40c9c13c70f3663e Author: ange Date: Tue Apr 30 23:08:27 2024 +0200 feat: k8sdeploy diff --git a/README.md b/README.md new file mode 100644 index 0000000..54e407c --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# checkout@v1 diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..bf1caed --- /dev/null +++ b/action.yaml @@ -0,0 +1,20 @@ +inputs: + kubeconfig: + description: kubeconfig file + required: true + registry_username: + description: Registry username + default: ${{ gitea.repository_owner }} + registry_password: + description: Registry password + +runs: + using: composite + steps: + - name: k8sdeploy + run: ${{ gitea.action_path }}/k8sdeploy.sh + env: + ACTION_REPO: ${{ gitea.repository }} + ACTION_KUBECONFIG: ${{ inputs.kubeconfig }} + ACTION_REGISTRY_USERNAME: ${{ inputs.registry_username }} + ACTION_REGISTRY_PASSWORD: ${{ inputs.registry_password }} diff --git a/k8sdeploy.sh b/k8sdeploy.sh new file mode 100755 index 0000000..89190a4 --- /dev/null +++ b/k8sdeploy.sh @@ -0,0 +1,23 @@ +#!/bin/bash -e +# shellcheck disable=SC1091 + +set -a +. ./.env +set +a + +REGISTRY="${IMAGEAPP%%/*}" +NS="${ACTION_REPO#*/}" + +mkdir -p "$HOME/.kube/" +echo "$ACTION_KUBECONFIG" > "$HOME/.kube/config" +kubectl get namespace "$NS" || kubectl create namespace "$NS" +kubectl config set-context --current --namespace="$NS" + +if [ -n "$ACTION_REGISTRY_PASSWD" ]; then + kubectl create secret docker-registry regcred \ + --docker-server="$REGISTRY" \ + --docker-username="$ACTION_REGISTRY_USER" \ + --docker-password="$ACTION_REGISTRY_PASSWD" +fi + +./manifests/bin/devel.sh