Skip to content

Commit

Permalink
[CI] Ensure publish-bundle.sh removes local image before creation and…
Browse files Browse the repository at this point in the history
… tagging.
  • Loading branch information
corneil committed Oct 6, 2023
1 parent fa85ef6 commit 0425bc1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/actions/publish-bundle/publish-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ if [ "$IMG_PKG_OPT" != "" ]; then
echo "IMG_PKG_OPT=$IMG_PKG_OPT"
fi
set +e
IMAGE_ID=$(docker images --digests --format json | jq -r IMAGE_URL "${REPOSITORY}" --arg TAG "${VERSION}" 'select(.Repository == $IMAGE_URL and .Tag == $TAG)' | jq -r --slurp 'map({ID: .ID}) | unique | .[] | .ID')
IMAGE_ID=$(docker images --digests --format json | jq -r --arg IMAGE_URL "$REPOSITORY" --arg TAG "$VERSION" 'select(.Repository == $IMAGE_URL and .Tag == $TAG)' | jq -r --slurp 'map({ID: .ID}) | unique | .[] | .ID')
if [ "$IMAGE_ID" != "" ]; then
docker rmi --force "$REPOSITORY:$VERSION"
echo "Removing all images with ID=$IMAGE_ID for $REPOSITORY"
docker images --digests | grep -F "$IMAGE_ID"
docker rmi --force $IMAGE_ID
fi
set -e
imgpkg push $IMG_PKG_OPT --bundle "$REPOSITORY:$VERSION-RANDOM.$RTAG" --file "$BUNDLE_PATH"
Expand Down

0 comments on commit 0425bc1

Please sign in to comment.