memorychat / quick_git_deploy.sh
artecnosomatic's picture
Initial commit: Memory Chat application
0919d5b
#!/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