Spaces:
Sleeping
Sleeping
| set -euo pipefail | |
| echo "π Deploying to Hugging Face Space..." | |
| # Resolve paths | |
| DEV_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | |
| HF_ROOT="${DEV_ROOT}/../kbdebugger-demo-hf" | |
| # Check HF repo exists | |
| if [ ! -d "$HF_ROOT/.git" ]; then | |
| echo "β HF repo not found at: $HF_ROOT" | |
| echo " Clone it first:" | |
| echo " git clone https://huggingface.co/spaces/faris-abuali/kbdebugger-demo kbdebugger-demo-hf" | |
| exit 1 | |
| fi | |
| # Sync files (exclude binaries and unnecessary dirs) | |
| echo "π Syncing files..." | |
| rsync -av --delete \ | |
| --exclude ".git/" \ | |
| --exclude "venv/" \ | |
| --exclude "__pycache__/" \ | |
| --exclude ".pytest_cache/" \ | |
| --exclude "logs/" \ | |
| --exclude ".env" \ | |
| --exclude "docs/" \ | |
| --exclude "data/" \ | |
| --exclude "notebooks/" \ | |
| --exclude "ui/static/img/" \ | |
| --exclude "README.md" \ | |
| "$DEV_ROOT/" "$HF_ROOT/" | |
| # Commit and push | |
| cd "$HF_ROOT" | |
| echo "π Committing changes..." | |
| git add -A | |
| git commit -m "Deploy $(date -Iseconds)" || echo "No changes to commit." | |
| echo "π€ Pushing to Hugging Face..." | |
| # Try the safe force first (protects against overwriting unexpected remote updates) | |
| if git push --force-with-lease; then | |
| echo "β Pushed with --force-with-lease." | |
| else | |
| echo "β οΈ --force-with-lease failed (likely remote moved and local didn't fetch)." | |
| echo " Falling back to plain --force for deploy mirror..." | |
| git push --force | |
| echo "β Pushed with --force." | |
| fi | |
| echo "β Deployment complete." |