#!/bin/bash
set -e

WORKSPACE_DIR="$HOME/.hermes/workspace"
cd "$WORKSPACE_DIR"

GIT_TOKEN="ef9dfa0b3ae3cfba010c1462b8f77e11a0d4289f"
GIT_USERNAME="ai_member_only"
GIT_EMAIL="ai@makee.com"
AGENT_NAME="xiaoai"
REPO_NAME="ai_member_${AGENT_NAME}"
GITEA_URL="https://git.valavala.com"

# Pull latest first
git pull origin main 2>/dev/null || true

# Add all changes
git add .

# Commit
if git diff --cached --quiet; then
  echo "✅ 无变更，跳过提交"
else
  git commit -m "auto backup $(date +'%Y-%m-%d %H:%M:%S')"
  git push origin main
  echo "✅ 备份完成并推送: $(date +'%Y-%m-%d %H:%M:%S')"
fi
