Skip to content

Commit

Permalink
fix: parameter expansion using circleci env subst (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricRibeiro committed Jul 26, 2023
1 parent 4d1fb6c commit 8d81a59
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ workflows:
- run:
command: |
echo "Digest is: $(</tmp/digest.txt)"
- gcp-gcr/build-and-push-image:
name: build-and-push-with-env-var
registry-url: us.gcr.io
image: ${CIRCLE_PROJECT_REPONAME}
tag: ${CIRCLE_SHA1:0:7}.$CIRCLE_BUILD_NUMBER
digest-path: /tmp/digest.txt
path: ~/project/sample/
docker-context: ~/project/sample/
context: cpe-gcp
filters: *filters
requires:
- integration-test
post-steps:
- run:
command: |
echo "Digest is: $(</tmp/digest.txt)"
- orb-tools/pack:
filters: *release-filters
- orb-tools/publish:
Expand All @@ -70,5 +86,6 @@ workflows:
- orb-tools/pack
- integration-test
- build-and-push
- build-and-push-with-env-var
context: orb-publisher
filters: *release-filters
8 changes: 8 additions & 0 deletions src/scripts/push-image.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
#!/bin/bash

ORB_VAL_REGISTRY_URL="$(circleci env subst "$ORB_VAL_REGISTRY_URL")"
ORB_VAL_IMAGE="$(circleci env subst "$ORB_VAL_IMAGE")"
ORB_VAL_DIGEST_PATH="$(circleci env subst "$ORB_VAL_DIGEST_PATH")"

IFS="," read -ra DOCKER_TAGS <<< "$ORB_EVAL_TAG"
PROJECT_ID="${!ORB_ENV_PROJECT_ID}"

for tag_to_eval in "${DOCKER_TAGS[@]}"; do
TAG=$(eval echo "$tag_to_eval")
set -x
docker push "$ORB_VAL_REGISTRY_URL/$PROJECT_ID/$ORB_VAL_IMAGE:$TAG"
set +x
done

if [ -n "$ORB_VAL_DIGEST_PATH" ]; then
mkdir -p "$(dirname "$ORB_VAL_DIGEST_PATH")"
SAMPLE_FIRST=$(eval echo "${DOCKER_TAGS[0]}")
set -x
docker image inspect --format="{{index .RepoDigests 0}}" "$ORB_VAL_REGISTRY_URL/$PROJECT_ID/$ORB_VAL_IMAGE:$SAMPLE_FIRST" > "$ORB_VAL_DIGEST_PATH"
set +x
fi

0 comments on commit 8d81a59

Please sign in to comment.