#!/usr/bin/env bash
# docker-push.sh — Tag and push dev image to Forgejo registry
# Usage: ./scripts/docker-push.sh
# Requires: ~/.openclaw/docker-registry.env (chmod 600)

set -euo pipefail
cd "$(dirname "$0")/.."

source ~/.openclaw/docker-registry.env

echo "$FORGEJO_REGISTRY_TOKEN" | docker login "$FORGEJO_REGISTRY" -u "$FORGEJO_REGISTRY_USER" --password-stdin

VERSION=$(node -e "console.log(require('./package.json').version)")
VERSION_TAG="dev-v${VERSION}"

docker tag bill-tracker:local "${FORGEJO_REGISTRY}/null/bill-tracker:dev"
docker tag bill-tracker:local "${FORGEJO_REGISTRY}/null/bill-tracker:${VERSION_TAG}"
docker push "${FORGEJO_REGISTRY}/null/bill-tracker:dev"
docker push "${FORGEJO_REGISTRY}/null/bill-tracker:${VERSION_TAG}"

docker logout "$FORGEJO_REGISTRY"
echo "✓ Pushed dev + ${VERSION_TAG} images"