#!/bin/bash

if [ "$#" -ne 2 ]; then
    echo "Usage: $0 <yml-file> <new-tag>"
    exit 1
fi

FILE="$1"
TAG="$2"

if [ ! -f "$FILE" ]; then
    echo "Error: File '$FILE' does not exist."
    exit 1
fi

sed -E -i \
    "s|(lettohub/[a-zA-Z0-9_.-]+:)[a-zA-Z0-9_.-]+|\1${TAG}|g" \
    "$FILE"

echo "Docker image tag changed to '$TAG' in '$FILE'."
