mirror of
https://github.com/aevea/action-kaniko.git
synced 2025-04-20 00:58:15 +02:00
feat: tag_with_latest option to add additional latest tag
With skip digest unchanged it is not enough the push the current tag, which is probably semvar, we also need to push the latest, so we can later check if the latest digest equal current tag
This commit is contained in:
parent
e5e4ca2afb
commit
b6cc2eed04
3 changed files with 20 additions and 0 deletions
|
@ -54,6 +54,7 @@ the most used values. So, technically there is a single required argument
|
||||||
| strip_tag_prefix | Prefix to be stripped from the tag | false | |
|
| strip_tag_prefix | Prefix to be stripped from the tag | false | |
|
||||||
| skip_unchanged_digest | Avoids pushing the image if the build generated the same digest | false | |
|
| skip_unchanged_digest | Avoids pushing the image if the build generated the same digest | false | |
|
||||||
| path | Path to the build context. Defaults to `.` | false | . |
|
| path | Path to the build context. Defaults to `.` | false | . |
|
||||||
|
| tag_with_latest | Tags the built image with additional latest tag | false | |
|
||||||
|
|
||||||
**Here is where it gets specific, as the optional arguments become required depending on the registry targeted**
|
**Here is where it gets specific, as the optional arguments become required depending on the registry targeted**
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,9 @@ inputs:
|
||||||
skip_unchanged_digest:
|
skip_unchanged_digest:
|
||||||
description: "Avoids pushing the image if the build generated the same digest"
|
description: "Avoids pushing the image if the build generated the same digest"
|
||||||
required: false
|
required: false
|
||||||
|
tag_with_latest:
|
||||||
|
description: "Tags the built image with additional latest tag"
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: "docker"
|
using: "docker"
|
||||||
image: "Dockerfile"
|
image: "Dockerfile"
|
||||||
|
|
|
@ -10,6 +10,7 @@ export TAG=${TAG#$INPUT_STRIP_TAG_PREFIX}
|
||||||
export USERNAME=${INPUT_USERNAME:-$GITHUB_ACTOR}
|
export USERNAME=${INPUT_USERNAME:-$GITHUB_ACTOR}
|
||||||
export PASSWORD=${INPUT_PASSWORD:-$GITHUB_TOKEN}
|
export PASSWORD=${INPUT_PASSWORD:-$GITHUB_TOKEN}
|
||||||
export REPOSITORY=$IMAGE
|
export REPOSITORY=$IMAGE
|
||||||
|
export IMAGE_LATEST=${INPUT_TAG_WITH_LATEST:+"$IMAGE:latest"}
|
||||||
export IMAGE=$IMAGE:$TAG
|
export IMAGE=$IMAGE:$TAG
|
||||||
export CONTEXT_PATH=${INPUT_PATH}
|
export CONTEXT_PATH=${INPUT_PATH}
|
||||||
|
|
||||||
|
@ -32,6 +33,10 @@ if [ "$REGISTRY" == "docker.pkg.github.com" ]; then
|
||||||
export IMAGE="$IMAGE_NAMESPACE/$IMAGE"
|
export IMAGE="$IMAGE_NAMESPACE/$IMAGE"
|
||||||
export REPOSITORY="$IMAGE_NAMESPACE/$REPOSITORY"
|
export REPOSITORY="$IMAGE_NAMESPACE/$REPOSITORY"
|
||||||
|
|
||||||
|
if [ ! -z $IMAGE_LATEST ]; then
|
||||||
|
export IMAGE_LATEST="$IMAGE_NAMESPACE/$IMAGE_LATEST"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -z $INPUT_CACHE_REGISTRY ]; then
|
if [ ! -z $INPUT_CACHE_REGISTRY ]; then
|
||||||
export INPUT_CACHE_REGISTRY="$REGISTRY/$IMAGE_NAMESPACE/$INPUT_CACHE_REGISTRY"
|
export INPUT_CACHE_REGISTRY="$REGISTRY/$IMAGE_NAMESPACE/$INPUT_CACHE_REGISTRY"
|
||||||
fi
|
fi
|
||||||
|
@ -41,6 +46,10 @@ if [ "$REGISTRY" == "docker.io" ]; then
|
||||||
export REGISTRY="index.${REGISTRY}/v1/"
|
export REGISTRY="index.${REGISTRY}/v1/"
|
||||||
else
|
else
|
||||||
export IMAGE="$REGISTRY/$IMAGE"
|
export IMAGE="$REGISTRY/$IMAGE"
|
||||||
|
|
||||||
|
if [ ! -z $IMAGE_LATEST ]; then
|
||||||
|
export IMAGE_LATEST="$REGISTRY/$IMAGE_LATEST"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export CACHE=${INPUT_CACHE:+"--cache=true"}
|
export CACHE=${INPUT_CACHE:+"--cache=true"}
|
||||||
|
@ -54,6 +63,9 @@ if [ ! -z $INPUT_SKIP_UNCHANGED_DIGEST ]; then
|
||||||
export DESTINATION="--no-push --digest-file digest"
|
export DESTINATION="--no-push --digest-file digest"
|
||||||
else
|
else
|
||||||
export DESTINATION="--destination $IMAGE"
|
export DESTINATION="--destination $IMAGE"
|
||||||
|
if [ ! -z $IMAGE_LATEST ]; then
|
||||||
|
export DESTINATION="$DESTINATION --destination $IMAGE_LATEST"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
||||||
|
@ -88,6 +100,10 @@ if [ ! -z $INPUT_SKIP_UNCHANGED_DIGEST ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export DESTINATION="--destination $IMAGE"
|
export DESTINATION="--destination $IMAGE"
|
||||||
|
if [ ! -z $IMAGE_LATEST ]; then
|
||||||
|
export DESTINATION="$DESTINATION --destination $IMAGE_LATEST"
|
||||||
|
fi
|
||||||
|
|
||||||
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
||||||
|
|
||||||
echo "Pushing image..."
|
echo "Pushing image..."
|
||||||
|
|
Loading…
Add table
Reference in a new issue