File size: 1,587 Bytes
51982d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

# --- Target selection (default: staging for safety) ---
TARGET="${1:-staging}"
case "$TARGET" in
    staging) HF_REPO="${HF_REPO:-serJD/ifcore-platform-staging}" ;;
    prod)    HF_REPO="${HF_REPO:-serJD/ifcore-platform}" ;;
    *)       echo "Usage: deploy.sh [staging|prod]"; exit 1 ;;
esac

echo "Deploying to $TARGET -> https://huggingface.co/spaces/$HF_REPO"

cd "$SCRIPT_DIR"

git -C "$SCRIPT_DIR/.." submodule update --init --recursive --remote

TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT

rsync -a --exclude='.git' --exclude='__pycache__' \
    --exclude='*.pdf' --exclude='*.png' --exclude='*.jpg' --exclude='*.jpeg' \
    --exclude='*.gif' --exclude='*.zip' --exclude='*.mp4' --exclude='*.mov' \
    --exclude='*.ifc' --exclude='*.ifczip' --exclude='*.glb' --exclude='*.obj' \
    . "$TMPDIR/"

find "$TMPDIR/teams" -name ".git" -type f -delete 2>/dev/null || true
find "$TMPDIR/teams" -name ".git" -type d -exec rm -rf {} + 2>/dev/null || true

cd "$TMPDIR"

git init -b main
git config user.email "deploy@ifcore"
git config user.name "IFCore Deploy"
git add .
git commit --no-gpg-sign -m "deploy($TARGET): $(date -u +%Y-%m-%dT%H:%M:%SZ)"
# Use token auth in CI (set HF_TOKEN env var or GitHub secret)
if [ -n "${HF_TOKEN:-}" ]; then
    HF_REMOTE="https://serJD:${HF_TOKEN}@huggingface.co/spaces/$HF_REPO"
else
    HF_REMOTE="https://huggingface.co/spaces/$HF_REPO"
fi
git remote add hf "$HF_REMOTE"
git push hf main --force

echo "Deployed to https://huggingface.co/spaces/$HF_REPO"