File size: 1,137 Bytes
b861e6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
set -e

SPACE_ID="${1:-N4YuC4/docneedle}"
COMMIT_MSG="${2:-Deploy DocNeedle updates}"

export PATH="$HOME/.local/bin:$PATH"

echo "==> Checking if Space exists: $SPACE_ID..."
if ! hf spaces info "$SPACE_ID" >/dev/null 2>&1; then
  echo "==> Space '$SPACE_ID' not found. Creating brand new Space with ZeroGPU..."
  hf repos create "$SPACE_ID" --type space --sdk gradio --flavor zero-a10g --public -e GRADIO_SSR_MODE=false
  echo "==> Space repository created successfully!"
else
  echo "==> Space '$SPACE_ID' already exists."
fi

echo "==> Deploying project files to $SPACE_ID..."

hf upload "$SPACE_ID" . . --repo-type space \
  --exclude ".git/**" \
  --exclude ".venv/**" \
  --exclude "models/**" \
  --exclude ".pytest_cache/**" \
  --exclude ".ruff_cache/**" \
  --exclude "**/__pycache__/**" \
  --exclude "tests/**" \
  --exclude ".env" \
  --exclude "*.pyc" \
  --commit-message "$COMMIT_MSG"

echo "==> Upload finished. Waiting for Space to build and reach RUNNING status..."
hf spaces wait "$SPACE_ID" --timeout 5m
echo "==> Successfully deployed! Space is live at: https://huggingface.co/spaces/$SPACE_ID"