#!/bin/bash # Deployment script for Hugging Face Spaces set -e echo "🚀 Hugging Face Spaces Deployment Script" echo "=========================================" echo "" # Check if git is initialized if [ ! -d ".git" ]; then echo "❌ Error: Not a git repository. Initialize with 'git init' first." exit 1 fi # Get repository name read -p "📝 Enter your Hugging Face Space name (e.g., username/space-name): " SPACE_NAME if [ -z "$SPACE_NAME" ]; then echo "❌ Error: Space name cannot be empty." exit 1 fi # Construct the URL SPACE_URL="https://huggingface.co/spaces/${SPACE_NAME}" echo "" echo "🔍 Checking if remote exists..." # Check if 'hf' remote already exists if git remote | grep -q "hf"; then echo "✅ Remote 'hf' already exists. Updating URL..." git remote set-url hf "$SPACE_URL" else echo "➕ Adding remote 'hf'..." git remote add hf "$SPACE_URL" fi echo "" echo "đŸ“Ļ Committing changes..." # Add all files git add . # Check if there are changes to commit if git diff --staged --quiet; then echo "â„šī¸ No changes to commit." else read -p "đŸ’Ŧ Enter commit message (default: 'Update demo'): " COMMIT_MSG COMMIT_MSG=${COMMIT_MSG:-"Update demo"} git commit -m "$COMMIT_MSG" fi echo "" echo "🚀 Pushing to Hugging Face Spaces..." git push hf main echo "" echo "✅ Deployment complete!" echo "🌐 Your Space will be available at: $SPACE_URL" echo "" echo "âąī¸ Note: It may take a few minutes for the Space to build and start."