File size: 2,011 Bytes
bd1531f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #!/usr/bin/env bash
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Deploy Oxinto AI backend to Hugging Face Spaces
# Usage: bash deploy.sh
# Requires: git, huggingface-cli (pip install huggingface_hub)
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
set -euo pipefail
HF_REPO="https://huggingface.co/spaces/ahn009/Oxinto-AI"
HF_REPO_GIT="https://huggingface.co/spaces/ahn009/Oxinto-AI"
DEPLOY_DIR="$(cd "$(dirname "$0")" && pwd)"
WORK_DIR="/tmp/oxinto-hf-deploy"
echo "π Deploying Oxinto AI backend to Hugging Face Spaces..."
# 1. Authenticate with HF (uses HF_TOKEN env var or cached login)
if [ -z "${HF_TOKEN:-}" ]; then
echo "β οΈ HF_TOKEN not set. Attempting cached login..."
huggingface-cli whoami || { echo "β Run: huggingface-cli login"; exit 1; }
fi
# 2. Clone or update the HF Space repo
if [ -d "$WORK_DIR/.git" ]; then
echo "π₯ Pulling latest from HF Space..."
git -C "$WORK_DIR" pull
else
echo "π₯ Cloning HF Space repo..."
rm -rf "$WORK_DIR"
GIT_LFS_SKIP_SMUDGE=1 git clone "$HF_REPO_GIT" "$WORK_DIR"
fi
# 3. Copy backend files into the cloned repo (overwrite)
echo "π Copying backend files..."
rsync -av --exclude='.git' --exclude='deploy.sh' "$DEPLOY_DIR/" "$WORK_DIR/"
# 4. Commit and push
cd "$WORK_DIR"
git add -A
git commit -m "Deploy Oxinto AI backend $(date '+%Y-%m-%d %H:%M')" || echo "Nothing to commit."
git push
echo ""
echo "β
Deployment complete!"
echo " Space URL : $HF_REPO"
echo " API URL : https://ahn009-oxinto-ai.hf.space"
echo " Health : https://ahn009-oxinto-ai.hf.space/health"
echo " Docs : https://ahn009-oxinto-ai.hf.space/docs"
|