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 required: true
runs: runs:
using: docker using: composite
image: Dockerfile steps:
args: - name: Build
- ACTION_DOCKERFILE=${{ inputs.dockerfile }} run: ${{ gitea.action_path }}/build.sh
- ACTION_TAG=${{ inputs.tag }} env:
- ACTION_REGISTRY=${{ gitea.server_url }} - ACTION_DOCKERFILE=${{ inputs.dockerfile }}
- ACTION_IMAGE=${{ gitea.repository }} - ACTION_TAG=${{ inputs.tag }}
- ACTION_USERNAME=${{ inputs.username }} - ACTION_REGISTRY=${{ gitea.server_url }}
- ACTION_PASSWORD=${{ inputs.password }} - 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 exec 3<> /dev/tty
eval "$*"
cat <<EOF > /kaniko/.docker/config.json cat <<EOF >&3
{ {
"auths": { "auths": {
"$ACTION_REGISTRY": { "$ACTION_REGISTRY": {
@ -14,8 +13,13 @@ cat <<EOF > /kaniko/.docker/config.json
} }
EOF EOF
REGISTRY="$(echo "$ACTION_REGISTRY" | sed 's .*:// ')" REGISTRY="${ACTION_REGISTRY/https:\/\/}"
/kaniko/executor \ docker run --rm \
--context "${ACTION_DOCKERFILE%/*}" \ -v "$PWD:$PWD:ro" \
--dockerfile "$ACTION_DOCKERFILE" \ -v "$HOME/.cache/kaniko:/cache" \
--destination "$REGISTRY/$ACTION_IMAGE:$ACTION_TAG" -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"