From 94f437184e754f30b76b7782e619cc8479aac771 Mon Sep 17 00:00:00 2001 From: Doron Somech Date: Sat, 20 Jun 2020 09:41:59 +0300 Subject: [PATCH] feat: Allow custom context path --- README.md | 1 + action.yml | 4 ++++ entrypoint.sh | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 79b0900..54ac7cf 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ the most used values. So, technically there is a single required argument | extra_args | Additional arguments to be passed to the kaniko executor | 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 | | +| path | Path to the build context. Defaults to `.` | 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 91db459..df1708d 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,10 @@ branding: icon: anchor color: orange inputs: + path: + description: Path to the build context + required: false + default: "." registry: description: "Docker registry where the image will be pushed" required: false diff --git a/entrypoint.sh b/entrypoint.sh index e62ba86..95bd64a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,6 +11,7 @@ export USERNAME=${INPUT_USERNAME:-$GITHUB_ACTOR} export PASSWORD=${INPUT_PASSWORD:-$GITHUB_TOKEN} export REPOSITORY=$IMAGE export IMAGE=$IMAGE:$TAG +export CONTEXT_PATH=${INPUT_PATH} function ensure() { if [ -z "${1}" ]; then @@ -24,6 +25,7 @@ ensure "${USERNAME}" "username" ensure "${PASSWORD}" "password" ensure "${IMAGE}" "image" ensure "${TAG}" "tag" +ensure "${CONTEXT_PATH}" "path" if [ "$REGISTRY" == "docker.pkg.github.com" ]; then IMAGE_NAMESPACE="$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')" @@ -45,8 +47,8 @@ export CACHE=${INPUT_CACHE:+"--cache=true"} export CACHE=$CACHE${INPUT_CACHE_TTL:+" --cache-ttl=$INPUT_CACHE_TTL"} 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" -export DOCKERFILE="--dockerfile ${INPUT_BUILD_FILE:-Dockerfile}" +export CONTEXT="--context $GITHUB_WORKSPACE/$CONTEXT_PATH" +export DOCKERFILE="--dockerfile $CONTEXT_PATH/${INPUT_BUILD_FILE:-Dockerfile}" if [ ! -z $INPUT_SKIP_UNCHANGED_DIGEST ]; then export DESTINATION="--no-push --digest-file digest"