From 71166e2407980136144043d4c33949ee8c0278f4 Mon Sep 17 00:00:00 2001 From: ange Date: Sun, 28 Apr 2024 23:16:33 +0200 Subject: [PATCH] first commit --- Dockerfile | 3 +++ README.md | 1 + action.yaml | 37 +++++++++++++++++++++++++++++++++++++ build.sh | 26 ++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yaml create mode 100755 build.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..736d40d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM gcr.io/kaniko-project/executor:debug +COPY build.sh /usr/local/bin/ +ENTRYPOINT ["build.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce4f569 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# kaniko@v1 diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..8f25763 --- /dev/null +++ b/action.yaml @@ -0,0 +1,37 @@ +name: kaniko +inputs: + dockerfile: + description: Dockerfile path + required: true + default: ./Dockerfile + registry: + description: Registry URL + required: true + default: git.gmoker.com + image: + description: Image name + required: true + default: ${{ gitea.repository }}:latest + username: + description: Registry username + required: true + default: ${{ gitea.repository_owner }} + password: + description: Registry password + required: true + default: ${{ gitea.token }} + tls: + description: Prevent push to http + required: true + default: true + +runs: + using: docker + image: Dockerfile + args: + - ACTION_DOCKERFILE=${{ inputs.dockerfile }} + - ACTION_REGISTRY=${{ inputs.registry }} + - ACTION_IMAGE=${{ inputs.image }} + - ACTION_USERNAME=${{ inputs.username }} + - ACTION_PASSWORD=${{ inputs.password }} + - ACTION_TLS=${{ inputs.tls }} diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..bc46e28 --- /dev/null +++ b/build.sh @@ -0,0 +1,26 @@ +#!/bin/sh -ex + +# source environment from args +eval "$*" + +ACTION=/kaniko/executor + +cat < /kaniko/.docker/config.json +{ + "auths": { + "$ACTION_REGISTRY": { + "username": "$ACTION_USERNAME", + "password": "$ACTION_PASSWORD" + } + } +} +EOF + +case "$ACTION_TLS" in + [fF]alse) ACTION="$ACTION --insecure" ;; + *) ;; +esac + +exec $ACTION \ + --dockerfile "$ACTION_DOCKERFILE" \ + --destination "$ACTION_REGISTRY/$ACTION_IMAGE"