diff --git a/README.md b/README.md index 7b4569f..a09a7ca 100644 --- a/README.md +++ b/README.md @@ -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** diff --git a/action.yml b/action.yml index a31b0dc..bc41cfb 100644 --- a/action.yml +++ b/action.yml @@ -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" diff --git a/entrypoint.sh b/entrypoint.sh index 4f944e1..d42a1c9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 </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..."