Bundling --context with arg in "" does not work

Try converting to bash to get access to arrays instead.
This commit is contained in:
Patrik Lundin 2025-02-05 20:29:37 +01:00
parent a516d1e2a2
commit 2138c52c9c
Signed by: patlu
GPG key ID: A0A812BA2249F294

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
# Setup auth
echo '{"auths":{"'"$(printf "%s" "$INPUT_REGISTRY")"'":{"auth":"'"$(printf "%s" "$INPUT_CREDENTIAL" | base64 | tr -d '\n')"'"}}}' > /kaniko/.docker/config.json
@ -8,10 +8,11 @@ if [ -n "$INPUT_WORKDIR" ]; then
printf 'cd %s -> %s\n' "$OLDPWD" "$PWD"
fi
context_flag=""
options=()
if [ -n "$INPUT_CONTEXT" ]; then
context_flag="--context $INPUT_CONTEXT"
options+=('--context')
options+=("$INPUT_CONTEXT")
fi
# Build container
/kaniko/executor --dockerfile "$INPUT_DOCKERFILE" --destination "$INPUT_REGISTRY/$INPUT_IMAGE" "$context_flag"
/kaniko/executor --dockerfile "$INPUT_DOCKERFILE" --destination "$INPUT_REGISTRY/$INPUT_IMAGE" "${options[@]}"