diff --git a/.scripts/actions/get_build_arguments.sh b/.scripts/actions/get_build_arguments.sh index 635be6c..3bd901b 100755 --- a/.scripts/actions/get_build_arguments.sh +++ b/.scripts/actions/get_build_arguments.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # Splits comma-separated values, prepends them with --build-arg, and prints -# them out separated by newlines. -echo "$1" | awk '{ split($0, args, ","); for (i in args) { printf "--build-arg \"%s\" ", args[i] }}' +# them out. Variable values MUST mot contain any whitespace as following commands +# will break. +echo "$1" | awk '{ split($0, args, ","); for (i in args) { printf "--build-arg %s ", args[i] }}' diff --git a/build-container-image/README.md b/build-container-image/README.md index 95cb4c8..d409d2d 100644 --- a/build-container-image/README.md +++ b/build-container-image/README.md @@ -21,7 +21,7 @@ All subsequent tasks must use this value to ensure consistency. - `image-index-manifest-tag` (required, eg: `3.4.1-stackable0.0.0-dev`) - `container-file` (defaults to `Dockerfile`) - `build-context` (defaults to `.`) -- `build-arguments` +- `build-arguments`: MUST not contain any whitespace ### Outputs diff --git a/build-container-image/action.yaml b/build-container-image/action.yaml index 34a5908..9816d67 100644 --- a/build-container-image/action.yaml +++ b/build-container-image/action.yaml @@ -19,7 +19,8 @@ inputs: default: . build-arguments: description: | - A comma-separated list of KEY=VALUE pairs provided as build arguments + A comma-separated list of KEY=VALUE pairs provided as build arguments. + MUST not contain any whitespace. outputs: image-repository-uri: description: | @@ -53,6 +54,12 @@ runs: run: | set -euo pipefail + # Validate that the build arguments input doesn't contain any whitespaces + if echo "$BUILD_ARGUMENTS" | grep '[[:space:]]'; then + >&2 echo "Build arguments MUST not contain any whitespace." + exit 1 + fi + DOCKER_BUILD_ARGUMENTS=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_build_arguments.sh" "$BUILD_ARGUMENTS") IMAGE_ARCH=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_architecture.sh") @@ -75,7 +82,7 @@ runs: --tag "${IMAGE_MANIFEST_URI}" \ --load \ $DOCKER_BUILD_ARGUMENTS \ - "${BUILD_CONTEXT}" + "$BUILD_CONTEXT" echo "::endgroup::" echo "::group::docker images"