#!/bin/bash # Colors GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color echo -e "${GREEN}🚀 Hugging Face Deployment Helper${NC}" echo "---------------------------------" echo -e "${YELLOW}Prerequisite:${NC} You must have created a Space on Hugging Face." echo " - URL: https://huggingface.co/new-space" echo " - SDK: Docker" echo "" # Check for Git if ! command -v git &> /dev/null; then echo -e "${RED}❌ Error: Git is not installed.${NC}" exit 1 fi # Get Space URL read -p "Enter your Hugging Face Space URL (e.g., https://huggingface.co/spaces/username/spacename): " SPACE_URL if [ -z "$SPACE_URL" ]; then echo -e "${RED}❌ Error: Space URL is required.${NC}" exit 1 fi # Initialize Git if [ ! -d ".git" ]; then echo "📦 Initializing Git repository..." git init # Set dummy config if not present (for this repo only) if [ -z "$(git config user.email)" ]; then git config user.email "deploy@example.com" git config user.name "Deployment Bot" fi else echo "📦 Git repository already initialized." fi # Add/Update Remote echo "🔗 Configuring remote..." if git remote | grep -q "origin"; then git remote set-url origin "$SPACE_URL" else git remote add origin "$SPACE_URL" fi # Pull (to handle initial commit from HF) echo "⬇️ Pulling remote changes..." git pull origin main --rebase || echo -e "${YELLOW}⚠️ Pull failed (might be empty repo), proceeding...${NC}" # Add Files echo "➕ Adding files..." git add Dockerfile requirements.txt start.sh forex_macd_strategy.py forex_macd_dashboard.html README.md # Commit echo "💾 Committing changes..." git commit -m "Deploying Forex MACD Dashboard with 3 TPs and Trailing SL" # Push echo -e "${GREEN}⬆️ Pushing to Hugging Face...${NC}" echo -e "${YELLOW}⚠️ Note: You will be asked for your Hugging Face Username and Password.${NC}" echo -e "${YELLOW} (Password should be an Access Token with 'write' permissions: https://huggingface.co/settings/tokens)${NC}" echo "" git push -u origin main if [ $? -eq 0 ]; then echo "" echo -e "${GREEN}✅ Deployment successful!${NC}" echo "Check your dashboard at: $SPACE_URL" else echo "" echo -e "${RED}❌ Deployment failed. Please check your credentials and try again.${NC}" fi