Skip to content

Commit

Permalink
fix: import the push.sh script in the push command (#131)
Browse files Browse the repository at this point in the history
* fix: import push script in the command

* fix: evaluate tag when digest path is set
  • Loading branch information
EricRibeiro committed Jun 13, 2022
1 parent 281e557 commit e7143bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
12 changes: 1 addition & 11 deletions src/commands/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,4 @@ steps:
PARAM_IMAGE: <<parameters.image>>
PARAM_TAG: <<parameters.tag>>
PARAM_DIGEST_PATH: <<parameters.digest-path>>
command: |
IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>"
for tag in "${DOCKER_TAGS[@]}"; do
docker push <<parameters.registry>>/<< parameters.image>>:${tag}
done
if [ -n "<<parameters.digest-path>>" ]; then
mkdir -p "$(dirname <<parameters.digest-path>>)"
IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>"
docker image inspect --format="{{index .RepoDigests 0}}" <<parameters.registry>>/<< parameters.image>>:"${DOCKER_TAGS[0]}" > "<<parameters.digest-path>>"
fi
command: << include(scripts/push.sh) >>
8 changes: 5 additions & 3 deletions src/scripts/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

IFS="," read -ra DOCKER_TAGS <<< "$PARAM_TAG"

for tag in "${DOCKER_TAGS[@]}"; do
docker push "$PARAM_REGISTRY"/"$PARAM_IMAGE":${tag}
for docker_tag in "${DOCKER_TAGS[@]}"; do
tag=$(eval echo "$docker_tag")
docker push "$PARAM_REGISTRY"/"$PARAM_IMAGE":"$tag"
done

if [ -n "$PARAM_DIGEST_PATH" ]; then
mkdir -p "$(dirname "$PARAM_DIGEST_PATH")"
IFS="," read -ra DOCKER_TAGS <<< "$PARAM_TAG"
docker image inspect --format="{{index .RepoDigests 0}}" "$PARAM_REGISTRY"/"$PARAM_IMAGE":"${DOCKER_TAGS[0]}" > "$PARAM_DIGEST_PATH"
tag=$(eval echo "${DOCKER_TAGS[0]}")
docker image inspect --format="{{index .RepoDigests 0}}" "$PARAM_REGISTRY"/"$PARAM_IMAGE":"$tag" > "$PARAM_DIGEST_PATH"
fi

0 comments on commit e7143bf

Please sign in to comment.