Compare commits
10 commits
2c6be10f61
...
85b42eee78
Author | SHA1 | Date | |
---|---|---|---|
85b42eee78 | |||
4c6d456a1c | |||
eff7472739 | |||
d1f56fe98d | |||
2b2a1ac12c | |||
dd103cf3b7 | |||
c92462e209 | |||
860ab947e4 | |||
84ec9cf196 | |||
6bf1ef88a2 |
4 changed files with 15 additions and 27 deletions
19
Dockerfile
19
Dockerfile
|
@ -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"]
|
|
|
@ -1 +1 @@
|
||||||
# k8sdeploy@v1
|
# k8sdeploy@v2
|
||||||
|
|
|
@ -4,12 +4,15 @@ inputs:
|
||||||
required: true
|
required: true
|
||||||
registry_username:
|
registry_username:
|
||||||
description: Registry username
|
description: Registry username
|
||||||
default: ${{ gitea.repository_owner }}
|
default: ${{ forgejo.repository_owner }}
|
||||||
registry_password:
|
registry_password:
|
||||||
description: Registry password
|
description: Registry password
|
||||||
|
workdir:
|
||||||
|
description: Working directory where to the action from
|
||||||
|
default: .
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- name: k8sdeploy
|
- name: k8sdeploy
|
||||||
run: ${{ gitea.action_path }}/k8sdeploy.sh
|
run: ${{ forgejo.action_path }}/entrypoint.sh
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
# shellcheck disable=SC1091
|
|
||||||
|
cd "$INPUT_WORKDIR"
|
||||||
|
|
||||||
set -a
|
set -a
|
||||||
|
# shellcheck disable=SC1091
|
||||||
. ./.env
|
. ./.env
|
||||||
set +a
|
set +a
|
||||||
|
|
||||||
REGISTRY="${IMAGEAPP%%/*}"
|
export K8S_NS;
|
||||||
NS="${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}"
|
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/"
|
mkdir -p "$HOME/.kube/"
|
||||||
echo "$INPUT_KUBECONFIG" > "$HOME/.kube/config"
|
echo "$INPUT_KUBECONFIG" > "$HOME/.kube/config"
|
||||||
kubectl get namespace "$NS" || kubectl create namespace "$NS"
|
kubectl get namespace "$K8S_NS" || kubectl create namespace "$K8S_NS"
|
||||||
kubectl config set-context --current --namespace="$NS"
|
kubectl config set-context --current --namespace="$K8S_NS"
|
||||||
|
|
||||||
if [ -n "$INPUT_REGISTRY_PASSWORD" ]; then
|
if [ -n "$INPUT_REGISTRY_PASSWORD" ]; then
|
||||||
kubectl get secret regcred \
|
kubectl get secret regcred \
|
Loading…
Add table
Add a link
Reference in a new issue