#!/bin/bash # Git deployment script for Hugging Face Spaces # This script adds, commits, and pushes all necessary files echo "=== Preparing files for Hugging Face Spaces deployment ===" # Step 1: Remove git lock file if exists if [ -f .git/index.lock ]; then echo "Removing git lock file..." rm -f .git/index.lock fi # Step 2: Add core application files (required for API to work) echo "" echo "Adding core application files..." git add app.py git add preprocessing.py git add model_utils.py git add requirements.txt git add Dockerfile # Step 3: Add configuration files echo "Adding configuration files..." git add .dockerignore git add .gitignore # Step 4: Add documentation files echo "Adding documentation files..." git add README_HF_SPACE.md git add DEPLOYMENT.md git add DEPLOYMENT_SUMMARY.md git add README.md # Step 5: Add models directory (if exists and not in .gitignore) if [ -d models ]; then echo "Checking models directory..." if ! grep -q "^models/" .gitignore 2>/dev/null; then echo "Adding models directory..." git add models/ else echo "WARNING: models/ is in .gitignore. You may need to force add it:" echo " git add -f models/" fi fi # Step 6: Show status echo "" echo "=== Files staged for commit ===" git status --short # Step 7: Commit echo "" echo "=== Committing changes ===" git commit -m "Deploy to Hugging Face Spaces: Add application files and dependencies - Add FastAPI application (app.py) - Add preprocessing module (preprocessing.py) - Add model utilities (model_utils.py) - Add Dockerfile for HF Spaces deployment - Add requirements.txt - Add deployment documentation - Add configuration files" if [ $? -eq 0 ]; then echo "" echo "=== Commit successful! ===" # Step 8: Push echo "" echo "=== Pushing to remote ===" echo "Note: You may need to authenticate for push" git push if [ $? -eq 0 ]; then echo "" echo "=== Deployment files pushed successfully! ===" echo "Next steps:" echo "1. Go to your Hugging Face Space" echo "2. Wait for automatic rebuild" echo "3. Check logs if build fails" else echo "" echo "=== Push failed ===" echo "You may need to:" echo "1. Set up authentication (git credential or token)" echo "2. Check remote URL: git remote -v" echo "3. Try: git push origin main" fi else echo "" echo "=== Commit failed ===" echo "Check git status and resolve any conflicts" fi echo "" echo "=== Script completed ==="