mirror of
https://github.com/aevea/action-kaniko.git
synced 2025-01-30 22:09:37 +01:00
feat: Add target option
This commit is contained in:
parent
79ed56ad90
commit
daf41b1e54
3 changed files with 7 additions and 2 deletions
|
@ -55,6 +55,7 @@ the most used values. So, technically there is a single required argument
|
|||
| skip_unchanged_digest | Avoids pushing the image if the build generated the same digest | false | |
|
||||
| path | Path to the build context. Defaults to `.` | false | . |
|
||||
| tag_with_latest | Tags the built image with additional latest tag | false | |
|
||||
| target | Sets the target stage to build | false | |
|
||||
|
||||
**Here is where it gets specific, as the optional arguments become required depending on the registry targeted**
|
||||
|
||||
|
|
|
@ -51,6 +51,9 @@ inputs:
|
|||
tag_with_latest:
|
||||
description: "Tags the built image with additional latest tag"
|
||||
required: false
|
||||
target:
|
||||
description: Sets the target stage to build
|
||||
required: false
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
|
|
|
@ -58,6 +58,7 @@ export CACHE=$CACHE${INPUT_CACHE_REGISTRY:+" --cache-repo=$INPUT_CACHE_REGISTRY"
|
|||
export CACHE=$CACHE${INPUT_CACHE_DIRECTORY:+" --cache-dir=$INPUT_CACHE_DIRECTORY"}
|
||||
export CONTEXT="--context $GITHUB_WORKSPACE/$CONTEXT_PATH"
|
||||
export DOCKERFILE="--dockerfile $CONTEXT_PATH/${INPUT_BUILD_FILE:-Dockerfile}"
|
||||
export TARGET=${INPUT_TARGET:+"--target=$INPUT_TARGET"}
|
||||
|
||||
if [ ! -z $INPUT_SKIP_UNCHANGED_DIGEST ]; then
|
||||
export DESTINATION="--no-push --digest-file digest"
|
||||
|
@ -68,7 +69,7 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
||||
export ARGS="$CACHE $CONTEXT $DOCKERFILE $TARGET $DESTINATION $INPUT_EXTRA_ARGS"
|
||||
|
||||
cat <<EOF >/kaniko/.docker/config.json
|
||||
{
|
||||
|
@ -104,7 +105,7 @@ if [ ! -z $INPUT_SKIP_UNCHANGED_DIGEST ]; then
|
|||
export DESTINATION="$DESTINATION --destination $IMAGE_LATEST"
|
||||
fi
|
||||
|
||||
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
||||
export ARGS="$CACHE $CONTEXT $DOCKERFILE $TARGET $DESTINATION $INPUT_EXTRA_ARGS"
|
||||
|
||||
echo "Pushing image..."
|
||||
|
||||
|
|
Loading…
Reference in a new issue