#!/bin/bash # Automated deployment script for Hugging Face # Load environment variables if [ -f "/home/ramram/Desktop/SELF_LEARNING/Medical RAG/.env" ]; then export $(grep -v '^#' "/home/ramram/Desktop/SELF_LEARNING/Medical RAG/.env" | xargs) fi if [ -z "$HF_TOKEN" ]; then echo "❌ Error: HF_TOKEN not found in .env" exit 1 fi DEST_DIR="/home/ramram/Desktop/SELF_LEARNING/Medical RAG/documents/Signal/hf_deployment" cd "$DEST_DIR" # Get Space URL from git remote SPACE_URL=$(git remote get-url origin) if [ -z "$SPACE_URL" ]; then echo "❌ Error: Git remote 'origin' not found. Please run deploy.sh manually once to set it up." exit 1 fi # Extract the repo path (e.g., dixitramjendra/MACD_Strategy) # Handle both https and ssh formats REPO_PATH=$(echo "$SPACE_URL" | sed -E 's|https://huggingface.co/spaces/||' | sed -E 's|git@huggingface.co:spaces/||' | sed -E 's|\.git$||') USERNAME=$(echo "$REPO_PATH" | cut -d'/' -f1) AUTH_URL="https://$USERNAME:$HF_TOKEN@huggingface.co/spaces/$REPO_PATH" echo "🚀 Starting automated deployment to $SPACE_URL..." # Add Files git add Dockerfile requirements.txt start.sh forex_macd_strategy.py forex_macd_dashboard.html forex_macd_signals.json signal_history.json active_signals.json README.md # Commit git commit -m "Automated deployment: Syncing latest signals and strategy" || echo "No changes to commit" # Push using token for authentication git push origin main --force if [ $? -eq 0 ]; then echo "✅ Deployment successful!" else echo "❌ Deployment failed." exit 1 fi