accounts/.github/scripts/utils/preferred-image-ref.sh
2026-04-12 13:42:48 +08:00

22 lines
326 B
Bash

#!/usr/bin/env bash
set -euo pipefail
tags="$1"
preferred=""
while IFS= read -r line; do
if [[ "$line" == *":latest" ]]; then
continue
fi
if [[ -n "$line" ]]; then
preferred="$line"
break
fi
done <<< "$tags"
if [[ -z "$preferred" ]]; then
preferred="$(echo "$tags" | head -n 1)"
fi
echo "$preferred"