diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index caebb45..8d8f638 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -39,7 +39,8 @@ promotion_requires: &promotion_requires test-machine-latest, test-machine-old, test-build-command-workspace, - test-build-with-args + test-build-with-args, + test-build-bash-substitution ] filters: &filters @@ -209,6 +210,20 @@ jobs: image: cpeorbtesting/docker-orb-test tag: $CIRCLE_BUILD_NUM-$CIRCLE_SHA1 extra_build_args: --build-arg COMMIT_HASH=$CIRCLE_SHA1 + test-build-bash-substitution: + docker: + - image: cimg/base:current + environment: + DOCKER_ACCOUNT: CPEOrbTesting + DOCKER_REPO: docker_orb_test + steps: + - checkout + - setup_remote_docker + - docker/build: + dockerfile: test3.Dockerfile + image: ${DOCKER_ACCOUNT,,}/${DOCKER_REPO,,/_/-} + tag: ${CIRCLE_BUILD_NUM,,}-${CIRCLE_SHA1:0:10} + extra_build_args: --build-arg COMMIT_HASH=$CIRCLE_SHA1 test-dockerlint: docker: - image: cimg/node:17.7.2 @@ -307,6 +322,8 @@ workflows: filters: *filters - test-build-with-args: filters: *filters + - test-build-bash-substitution: + filters: *filters # begin test-install-docker-compose - test-install-docker-compose: diff --git a/src/examples/with-bash-substitution.yml b/src/examples/with-bash-substitution.yml new file mode 100644 index 0000000..e49d215 --- /dev/null +++ b/src/examples/with-bash-substitution.yml @@ -0,0 +1,15 @@ +description: > + Build/publish a Docker image bash substitution + +usage: + version: 2.1 + + orbs: + docker: circleci/docker@x.y.z + + workflows: + build-docker-image-only: + jobs: + - docker/publish: + image: ${CIRCLE_PROJECT_USERNAME,,}/${CIRCLE_PROJECT_REPONAME/_/-} + tag: ${CIRCLE_SHA1:0:10} diff --git a/src/scripts/build.sh b/src/scripts/build.sh index 55daf7c..d49167e 100644 --- a/src/scripts/build.sh +++ b/src/scripts/build.sh @@ -23,6 +23,8 @@ parse_tags_to_docker_arg() { fi done + # Set IFS to null to stop "," from breaking bash substitution + local IFS= DOCKER_TAGS_ARG="$(eval echo $docker_arg)" } diff --git a/test3.Dockerfile b/test3.Dockerfile index e0d8db5..cdc9a11 100644 --- a/test3.Dockerfile +++ b/test3.Dockerfile @@ -11,7 +11,6 @@ ARG COMMIT_HASH # Change default shell from Dash to Bash RUN rm /bin/sh && ln -s /bin/bash /bin/sh - RUN if [[ "${COMMIT_HASH}" =~ ^[0-9a-f]{5,40}$ ]]; then \ echo "Success: COMMIT_HASH is valid commit hash"; \ else \