diff --git a/entrypoint.sh b/entrypoint.sh index e788283d173435ea33262edc85ca22d8793fe8e5..9713106e5ecf0a47d915d06766bb6261977bf938 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -12,7 +12,7 @@ die() { RED='\033[0;31m' NC='\033[0m' # No Color echo -e "${RED}$1${NC}" - test -z "${RETAG_DEBUG}" || exit 1 + exit 1 } ########################################################################################################################## @@ -28,20 +28,31 @@ test -z "${CI_REGISTRY_PASSWORD}" && should_die "CI_REGISTRY_PASSWORD is missing test -z "${CI_PROJECT_PATH}" && should_die "CI_PROJECT_PATH is missing" test -z "${CI_COMMIT_SHA}" && should_die "CI_COMMIT_SHA is missing" +if test -z "${CI_APPLICATION_TAG}" && test -z "${REGISTRY_TAG_OLD}";then + should_die "Neither CI_APPLICATION_TAG nor REGISTRY_TAG_OLD was set!" +fi +if test -n "${CI_APPLICATION_TAG}" && test -n "${REGISTRY_TAG_OLD}";then + should_die "Both CI_APPLICATION_TAG and REGISTRY_TAG_OLD were set!" +fi + ########################################################################################################################## -test -n "${SHOULD_DIE}" && die "Incomplete config!" +test -n "${SHOULD_DIE}" && die "Wrong config!" ########################################################################################################################## # DEBUG test -z "${RETAG_DEBUG}" || set -x +# TEST +if test -z "${CI_COMMIT_TAG}" && test -z "${REGISTRY_TAG_OLD}"; then + REGISTRY_TAG_OLD="${CI_APPLICATION_TAG%%@*}" + CUSTOM_IMAGENAME="${CI_COMMIT_REF_SLUG}" +elif test -n "${CI_COMMIT_TAG}" && test -z "${REGISTRY_TAG_OLD}"; then + REGISTRY_TAG_OLD="${CI_COMMIT_TAG}" +fi + # Define default custom image name -test -z "${CUSTOM_IMAGENAME}" && test -z "${CI_COMMIT_TAG}" && CUSTOM_IMAGENAME="${CI_COMMIT_REF_SLUG}" test -z "${CUSTOM_IMAGENAME}" && IMAGE_PATH="${CI_PROJECT_PATH}" || IMAGE_PATH="${CI_PROJECT_PATH}/${CUSTOM_IMAGENAME}" -# Define default image old tag -test -z "${REGISTRY_TAG_OLD}" && ( test -z "${CI_COMMIT_TAG}" && REGISTRY_TAG_OLD="${CI_COMMIT_SHA}" || REGISTRY_TAG_OLD="${CI_COMMIT_TAG}" ) - # Define default image new tag test -z "${REGISTRY_TAG_NEW}" && REGISTRY_TAG_NEW=latest