#!/usr/bin/env bash
set -euo pipefail

targets=(
  ".gitea/workflows/deploy.yml"
  "deploy_gb.sh"
)

for file in "${targets[@]}"; do
  if [ ! -f "$file" ]; then
    echo "Missing KST target file: $file" >&2
    exit 1
  fi
done

if grep -nE 'date \+%Y%m%d_%H%M%S|date \+%Y%m%d' "${targets[@]}" | grep -v 'TZ=Asia/Seoul' >/dev/null; then
  echo "Timestamp generation must use TZ=Asia/Seoul." >&2
  exit 1
fi

echo "KST timestamp harness passed."
