feat: cache

This commit is contained in:
ange 2024-05-02 16:38:09 +02:00
parent 2c7bab8c91
commit e06631721b
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
3 changed files with 24 additions and 21 deletions

View File

@ -1,3 +0,0 @@
FROM gcr.io/kaniko-project/executor:debug
COPY build.sh /usr/local/bin/
ENTRYPOINT ["build.sh"]

View File

@ -16,12 +16,14 @@ inputs:
required: true
runs:
using: docker
image: Dockerfile
args:
- ACTION_DOCKERFILE=${{ inputs.dockerfile }}
- ACTION_TAG=${{ inputs.tag }}
- ACTION_REGISTRY=${{ gitea.server_url }}
- ACTION_IMAGE=${{ gitea.repository }}
- ACTION_USERNAME=${{ inputs.username }}
- ACTION_PASSWORD=${{ inputs.password }}
using: composite
steps:
- name: Build
run: ${{ gitea.action_path }}/build.sh
env:
- ACTION_DOCKERFILE=${{ inputs.dockerfile }}
- ACTION_TAG=${{ inputs.tag }}
- ACTION_REGISTRY=${{ gitea.server_url }}
- ACTION_IMAGE=${{ gitea.repository }}
- ACTION_USERNAME=${{ inputs.username }}
- ACTION_PASSWORD=${{ inputs.password }}

22
build.sh Executable file → Normal file
View File

@ -1,9 +1,8 @@
#!/bin/sh -ex
#!/bin/bash -e
# source environment from args
eval "$*"
exec 3<> /dev/tty
cat <<EOF > /kaniko/.docker/config.json
cat <<EOF >&3
{
"auths": {
"$ACTION_REGISTRY": {
@ -14,8 +13,13 @@ cat <<EOF > /kaniko/.docker/config.json
}
EOF
REGISTRY="$(echo "$ACTION_REGISTRY" | sed 's .*:// ')"
/kaniko/executor \
--context "${ACTION_DOCKERFILE%/*}" \
--dockerfile "$ACTION_DOCKERFILE" \
--destination "$REGISTRY/$ACTION_IMAGE:$ACTION_TAG"
REGISTRY="${ACTION_REGISTRY/https:\/\/}"
docker run --rm \
-v "$PWD:$PWD:ro" \
-v "$HOME/.cache/kaniko:/cache" \
-v "/proc/$$/fd/3:/kaniko/.docker/config.json:ro" \
gcr.io/kaniko-project/executor:latest \
--cache true \
--context "${ACTION_DOCKERFILE%/*}" \
--dockerfile "$ACTION_DOCKERFILE" \
--destination "$REGISTRY/$ACTION_IMAGE:$ACTION_TAG"