Files
zitadel/login/scripts/run_or_skip.sh
T
2928c6ac2b chore(login): migrate nextjs login to monorepo (#10134)
# Which Problems Are Solved

We move the login code to the zitadel repo.

# How the Problems Are Solved

The login repo is added to ./login as a git subtree pulled from the
dockerize-ci branch.
Apart from the login code, this PR contains the changes from #10116

# Additional Context

- Closes https://github.com/zitadel/typescript/issues/474
- Also merges #10116  
- Merging is blocked by failing check because of:
- https://github.com/zitadel/zitadel/pull/10134#issuecomment-3012086106

---------

Co-authored-by: Max Peintner <[email protected]>
Co-authored-by: Max Peintner <[email protected]>
Co-authored-by: Florian Forster <[email protected]>
2025-07-02 10:04:19 +02:00

68 lines
2.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Usage: ./run_or_skip.sh <Make target> <images>
# Example: ./run_or_skip.sh lint-force "img1;img2"
set -euo pipefail
if [ -z "$CACHE_DIR" ]; then
echo "CACHE_DIR is not set. Please set it to a valid directory."
exit 1
fi
MAKE_TARGET=$1
IMAGES=$2
IGNORE_RUN_CACHE=${IGNORE_RUN_CACHE:-false}
CACHE_FILE="$CACHE_DIR/$MAKE_TARGET.digests"
mkdir -p "$CACHE_DIR"
get_image_creation_dates() {
local values=""
for img in $(echo "$IMAGES"); do
local value=$(docker image inspect "$img" --format='{{.Created}}' 2>/dev/null || true)
if [[ -z $value ]]; then
docker pull "$img" >/dev/null 2>&1 || true
value=$(docker image inspect "$img" --format='{{.Created}}' 2>/dev/null || true)
fi
if [[ -z $value ]]; then
value=$(docker image inspect "$img" --format='{{.Created}}' 2>/dev/null || true)
fi
value=${value:-new-and-not-pullable-or-failed-to-build}
value="${img}@${value}"
values="${values}${value};"
done
values=${values%;} # Remove trailing semicolon
echo "$values"
}
CACHE_FILE_CONTENT=$(cat "$CACHE_FILE" 2>/dev/null || echo "")
CACHED_STATUS=$(echo "$CACHE_FILE_CONTENT" | cut -d ';' -f1)
CACHED_IMAGE_CREATED_VALUES=$(echo "$CACHE_FILE_CONTENT" | cut -d ';' -f2-99)
CURRENT_IMAGE_CREATED_VALUES="$(get_image_creation_dates)"
if [[ "$CACHED_IMAGE_CREATED_VALUES" == "$CURRENT_IMAGE_CREATED_VALUES" ]]; then
if [[ "$IGNORE_RUN_CACHE" == "true" ]]; then
echo "\$IGNORE_RUN_CACHE=$IGNORE_RUN_CACHE - Running $MAKE_TARGET despite unchanged images."
else
echo "Skipping $MAKE_TARGET – all images unchanged, returning cached status $CACHED_STATUS"
exit $CACHED_STATUS
fi
fi
echo "Images have changed"
echo
echo "CACHED_IMAGE_CREATED_VALUES does not match CURRENT_IMAGE_CREATED_VALUES"
echo
echo "$CACHED_IMAGE_CREATED_VALUES"
echo
echo "$CURRENT_IMAGE_CREATED_VALUES"
echo
docker images
echo
echo "Running $MAKE_TARGET..."
set +e
make -j $MAKE_TARGET
STATUS=$?
set -e
echo "${STATUS};$(get_image_creation_dates)" > $CACHE_FILE
exit $STATUS