#!/usr/bin/env bash # Puts the stack back on the previous tag (GK_PREVIOUS_TAG) and swaps the two, # so running it again rolls forward. See docs/deploy.md. set -euo pipefail STACK="${GK_STACK_DIR:-/home/greg/homelab/gregkilmer}" ENV_FILE="$STACK/.env" cur="$(grep -E '^GK_TAG=' "$ENV_FILE" | cut -d= -f2-)" prev="$(grep -E '^GK_PREVIOUS_TAG=' "$ENV_FILE" | cut -d= -f2-)" [ -n "$prev" ] || { echo "No GK_PREVIOUS_TAG in $ENV_FILE"; exit 1; } sed -i "s|^GK_TAG=.*|GK_TAG=$prev|; s|^GK_PREVIOUS_TAG=.*|GK_PREVIOUS_TAG=$cur|" "$ENV_FILE" docker compose --project-directory "$STACK" -f "$STACK/compose.yaml" up -d --wait --wait-timeout 120 echo "Now running $prev (previous: $cur)"