diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 956f96f..0000000 --- a/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM debian:12-slim as kubectl -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - ca-certificates \ - curl \ - && rm -rf /var/lib/apt/lists/* -RUN V="$(curl -sSL https://dl.k8s.io/release/stable.txt)" \ - && curl -Lo /kubectl "https://dl.k8s.io/release/$V/bin/linux/amd64/kubectl" - -FROM debian:12-slim -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* -COPY --from=kubectl --chmod=0755 /kubectl /usr/local/bin/ -COPY k8sdeploy.sh /usr/local/bin/ -RUN useradd -m app -USER app -ENTRYPOINT ["k8sdeploy.sh"] diff --git a/README.md b/README.md index 4c20a30..721e56c 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# k8sdeploy@v1 +# k8sdeploy@v2 diff --git a/action.yaml b/action.yaml index 0fe3cdb..38a588a 100644 --- a/action.yaml +++ b/action.yaml @@ -4,12 +4,15 @@ inputs: required: true registry_username: description: Registry username - default: ${{ gitea.repository_owner }} + default: ${{ forgejo.repository_owner }} registry_password: description: Registry password + workdir: + description: Working directory where to the action from + default: . runs: using: composite steps: - name: k8sdeploy - run: ${{ gitea.action_path }}/k8sdeploy.sh + run: ${{ forgejo.action_path }}/entrypoint.sh diff --git a/k8sdeploy.sh b/entrypoint.sh similarity index 62% rename from k8sdeploy.sh rename to entrypoint.sh index fc27005..d60e163 100755 --- a/k8sdeploy.sh +++ b/entrypoint.sh @@ -1,17 +1,21 @@ #!/bin/bash -e -# shellcheck disable=SC1091 + +cd "$INPUT_WORKDIR" set -a +# shellcheck disable=SC1091 . ./.env set +a -REGISTRY="${IMAGEAPP%%/*}" -NS="${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}" +export K8S_NS; +K8S_NS="$(printf '%s' "${GITHUB_REPOSITORY//\//-}-$GITHUB_REF_NAME" \ + | tr '[:upper:]' '[:lower:]' | tr -c '[:lower:][:digit:]-' - \ + | sed 's/-\+/-/g; s/^-\+//; s/-$//')" mkdir -p "$HOME/.kube/" echo "$INPUT_KUBECONFIG" > "$HOME/.kube/config" -kubectl get namespace "$NS" || kubectl create namespace "$NS" -kubectl config set-context --current --namespace="$NS" +kubectl get namespace "$K8S_NS" || kubectl create namespace "$K8S_NS" +kubectl config set-context --current --namespace="$K8S_NS" if [ -n "$INPUT_REGISTRY_PASSWORD" ]; then kubectl get secret regcred \