#!/bin/bash # Quick Git Deployment to Hugging Face Spaces # Run this script to deploy your Memory Chat application echo "🚀 Memory Chat - Quick Git Deployment to Hugging Face Spaces" echo "==============================================================" # Check if git is installed if ! command -v git &> /dev/null; then echo "❌ Git is not installed. Please install Git first." exit 1 fi # Check if required files exist required_files=("app.py" "memory_manager.py" "chat_interface.py" "config.py" "requirements.txt" "README.md") for file in "${required_files[@]}"; do if [ ! -f "$file" ]; then echo "❌ Missing file: $file" echo "Please ensure all required files are in the current directory." exit 1 fi done echo "✅ All required files found" # Get user input read -p "Enter your Hugging Face username: " username read -p "Enter your Space name (e.g., memory-chat): " space_name # Check if this is a new Space or existing echo "" echo "Is this a new Space? (y/n)" read -p "Choice [y/n]: " new_space if [ "$new_space" = "y" ] || [ "$new_space" = "Y" ]; then echo "" echo "🌐 Creating new Space..." echo "Please create your Space at: https://huggingface.co/spaces/new" echo "" echo "Space details:" echo "- Name: $space_name" echo "- Type: Gradio" echo "- Visibility: Public" echo "" echo "After creating the Space, press Enter to continue..." read fi # Setup Git echo "" echo "🔧 Setting up Git repository..." # Initialize if not already if [ ! -d ".git" ]; then git init fi # Get Hugging Face token echo "" echo "🔐 Getting Hugging Face credentials..." echo "Please get your Hugging Face API token:" echo "1. Go to: https://huggingface.co/settings/tokens" echo "2. Click 'New token'" echo "3. Set name: 'spaces-deploy'" echo "4. Set role: 'write'" echo "5. Copy the token" echo "" read -s -p "Enter your Hugging Face API token: " hf_token echo "" # Setup remote URL remote_url="https://$username:$hf_token@huggingface.co/spaces/$username/$space_name" # Remove existing remote if exists git remote remove origin 2>/dev/null || true # Add remote git remote add origin "$remote_url" echo "✅ Git remote configured" # Add files and commit echo "" echo "📁 Preparing files..." git add . git commit -m "Initial commit: Memory Chat application" echo "✅ Files committed" # Push to Hugging Face echo "" echo "🚀 Deploying to Hugging Face Spaces..." if git push -u origin main; then echo "" echo "🎉 Successfully deployed!" echo "🌐 Your Space: https://huggingface.co/spaces/$username/$space_name" echo "" echo "💡 Check the 'Logs' tab in your Space for build progress." echo "💡 Your Space should be live in 3-5 minutes." else echo "❌ Deployment failed. Trying force push..." if git push -u origin main --force; then echo "" echo "🎉 Successfully deployed (force push)!" echo "🌐 Your Space: https://huggingface.co/spaces/$username/$space_name" else echo "❌ Failed to deploy. Please check your credentials and try again." exit 1 fi fi