Spaces:
Sleeping
Sleeping
File size: 2,325 Bytes
b3b70f8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #!/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
|