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

# Run on the development ECS after the repository is cloned or pulled.
# Expected public location:
#   /workspace/developSite/zhctprompt/bid-analysis-methodology

PUBLIC_BASE_URL="${PUBLIC_BASE_URL:-http://zhctpmt.yyangpt.cn/bid-analysis-methodology}"
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

required_files=(
  "README.md"
  "index.html"
  "docs/reports/2026-h1-yifangbao-business-report.html"
  "docs/workflow-skill-deposition-guide.html"
)

for file in "${required_files[@]}"; do
  if [[ ! -f "${REPO_ROOT}/${file}" ]]; then
    echo "[deploy] missing required file: ${file}" >&2
    exit 1
  fi
done

chmod -R a+rX "${REPO_ROOT}"

echo "[deploy] bid-analysis-methodology files are ready"
echo "[deploy] public entry: ${PUBLIC_BASE_URL}/"
echo "[deploy] business report: ${PUBLIC_BASE_URL}/docs/reports/2026-h1-yifangbao-business-report.html"
echo "[deploy] project guide: ${PUBLIC_BASE_URL}/docs/workflow-skill-deposition-guide.html"
