#!/usr/bin/env bash # Copyright 2020-2024 the Pinniped contributors. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail SOURCE_REPOSITORY="$(cat ci-build-image/repository)" SOURCE_DIGEST="$(cat ci-build-image/digest)" SOURCE_IMAGE="${SOURCE_REPOSITORY}@${SOURCE_DIGEST}" SOURCE_REGISTRY="$(echo "$SOURCE_REPOSITORY" | cut -d / -f 1)" DESTINATION_REGISTRY="$(echo "$DESTINATION_REPOSITORY" | cut -d / -f 1)" # Login to both the source and the dest. echo "Logging in to $SOURCE_REPOSITORY_USERNAME ..." crane auth login -u "$SOURCE_REGISTRY" -p "$SOURCE_REPOSITORY_PASSWORD" "$SOURCE_REGISTRY" echo "Logging in to $DESTINATION_REGISTRY ..." crane auth login -u "$DESTINATION_REPOSITORY_USERNAME" -p "$DESTINATION_REPOSITORY_PASSWORD" "$DESTINATION_REGISTRY" # Create an array of all desired tags. echo "Collecting desired tags ..." DESTINATION_TAGS=() # Add the destination tag, if one was specified. if [[ -n "$DESTINATION_TAG" ]]; then echo "Saw desired tag $DESTINATION_TAG" DESTINATION_TAGS+=("$DESTINATION_TAG") fi # Add each tag from input file release-info/image-tags. while IFS="" read -r tag || [ -n "$tag" ]; do echo "Saw desired tag $tag" DESTINATION_TAGS+=("$tag") done