PublishImage/scripts/ensure_lowercase.sh
mrrpnya 924bc279d9
Some checks failed
Test Deploy to OCI Registry / deploy (push) Failing after 3m34s
.
2025-03-06 16:13:20 -08:00

19 lines
No EOL
656 B
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

#!/bin/sh
# Ensure specified environment variable is lowercase
# specify the environment variable to validate as an argument (or array of arguments)
# reserve first argument for the environment variable name
ENV_VAR_NAME=$1
# Check if the environment variable is lowercase
for var in "${@:2}"; do
# get the value of the specified environment variable
value=$(eval echo \$$var)
# check if the value is lowercase
if [[ "$value" != "${value,,}" ]]; then
echo "❌ Invalid $ENV_VAR_NAME: $value"
echo " $ENV_VAR_NAME must be lowercase"
exit 1
else
echo "$ENV_VAR_NAME is valid: $value"
fi
done