Skip to content

Commit ba22092

Browse files
committed
Update caching and fix typo
1 parent 244fc96 commit ba22092

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

build-and-push.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ set -xeuo pipefail
1313
# DRY_RUN - when set, skip all push operations (e.g. set for PR builds)
1414

1515
IMAGE="${TO_IMAGE}:${TO_TAG}-${ARCH}"
16-
export TO_REGISTRY=${TO_IMAGE%%/*}
16+
TO_REGISTRY=$(echo "$TO_IMAGE" | cut -d/ -f1)
17+
export TO_REGISTRY
1718

18-
./login.sh
19+
. ./login.sh
1920

2021
if [ -n "${USE_CACHE:-}" ]; then
2122
CACHE_IMAGE_FULL="${CACHE_IMAGE}:${TO_TAG}-${ARCH}"
@@ -46,5 +47,5 @@ fi
4647
if [ -z "${DRY_RUN:-}" ] && [ -n "${USE_CACHE:-}" ]; then
4748
buildah push "$IMAGE" "$CACHE_IMAGE_FULL"
4849
elif [ -n "${DRY_RUN:-}" ] && [ -n "${USE_CACHE:-}" ]; then
49-
echo "Push skipped: DRY_RUN is set or REPO_USERNAME or REPO_PASSWORD missing"
50+
echo "Push to cache skipped: DRY_RUN is set or REPO_USERNAME or REPO_PASSWORD missing"
5051
fi

generate-manifests.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ set -xeuo pipefail
1111
# CACHE_IMAGE, CACHE_USERNAME, CACHE_PASSWORD - sidecar cache registry (optional)
1212
# DRY_RUN - when set, skip all push operations (e.g. set for PR builds)
1313

14-
export TO_REGISTRY=${IMAGE%%/*}
14+
TO_REGISTRY=$(echo "$IMAGE" | cut -d/ -f1)
15+
export TO_REGISTRY
1516

16-
./login.sh
17+
. ./login.sh
1718

1819
echo "Creating manifest for $IMAGE:$TAG"
1920
buildah manifest rm "$IMAGE:$TAG" 2>/dev/null || true

login.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -xeuo pipefail
33

4-
if [ -n "${REPO_USERNAME:-}" ] && [ -n "${REPO_PASSWORD:-}" ]; the
4+
if [ -n "${REPO_USERNAME:-}" ] && [ -n "${REPO_PASSWORD:-}" ]; then
55
echo "Logging in to $TO_REGISTRY"
66
echo "$REPO_PASSWORD" | buildah login -u "$REPO_USERNAME" --password-stdin "$TO_REGISTRY"
77
elif [ -n "${AWS_REGION:-}" ] && [ -n "${AWS_ACCESS_KEY_ID:-}" ] && [ -n "${AWS_SECRET_ACCESS_KEY:-}" ]; then
@@ -13,7 +13,7 @@ fi
1313
USE_CACHE=
1414
if [ -n "${CACHE_IMAGE:-}" ] && [ -n "${CACHE_USERNAME:-}" ] && [ -n "${CACHE_PASSWORD:-}" ]; then
1515
USE_CACHE=1
16-
CACHE_REGISTRY=${CACHE_IMAGE%%/*}
16+
CACHE_REGISTRY=$(echo "$CACHE_IMAGE" | cut -d/ -f1)
1717
echo "Logging in to $CACHE_REGISTRY (cache will be used)"
1818
echo "$CACHE_PASSWORD" | buildah login -u "$CACHE_USERNAME" --password-stdin "$CACHE_REGISTRY"
1919
fi

0 commit comments

Comments
 (0)