animebot / DEPLOY.md
luci18's picture
Upload folder using huggingface_hub
e4ccb70 verified
|
Raw History Blame Contribute Delete
3.66 kB

πŸš€ Deploy to GitHub + Hugging Face

Quick Start

1. Initialize & Push to GitHub

Windows:

setup-github.bat

Linux/Mac:

bash setup-github.sh

2. Manual GitHub Push

# Replace with your actual repo
git remote add origin https://github.com/YOUR_USERNAME/anime-encoder-bot.git
git push -u origin main

3. Create Hugging Face Space

  1. Go to: https://huggingface.co/new-space
  2. Owner: Select your username
  3. Space Name: anime-encoder-bot
  4. SDK: Select Docker
  5. Space Hardware: CPU Basic (free) or GPU for faster encoding
  6. Click Create Space

4. Configure GitHub Secrets

In your GitHub repo, go to Settings > Secrets and variables > Actions:

Add this secret:

Secret Name Value Example
HF_SPACE_ID Your space ID itzmelucifer/anime-encoder-bot

βœ… HF_TOKEN is already configured in the workflow file.

OR Push Directly (No GitHub needed):

push-hf.bat

Enter your space ID when prompted.

5. Hugging Face Environment Variables

In your Space, go to Settings > Variables:

API_ID=your_api_id
API_HASH=your_api_hash
BOT_TOKEN=your_bot_token
OWNER_ID=your_telegram_id
MONGO_URI=mongodb+srv://...
ADMIN_USERNAME=admin
ADMIN_PASSWORD_HASH=bcrypt_hash
FLASK_SECRET_KEY=random_secret
FFMPEG_PATH=ffmpeg
FFPROBE_PATH=ffprobe

6. Deploy

Once secrets are set, every push to GitHub will auto-deploy to Hugging Face!

Manual deploy trigger:

  • Go to Actions tab in GitHub
  • Click Deploy to Hugging Face
  • Click Run workflow

πŸ“‹ Setup Checklist

  • GitHub repository created
  • Code pushed to GitHub
  • Hugging Face Space created (Docker SDK)
  • GitHub secrets: HF_TOKEN, HF_SPACE_ID
  • Hugging Face environment variables set
  • First deployment successful

πŸ”§ Troubleshooting

Git push fails?

git pull origin main --rebase
git push -u origin main

Hugging Face deploy fails?

  1. Check GitHub Actions logs
  2. Verify HF_TOKEN is correct
  3. Check HF_SPACE_ID format (must be username/space-name)

Bot not starting?

  1. Check Hugging Face logs in Space
  2. Verify all env variables are set
  3. Check MongoDB connection string is accessible from Hugging Face

MongoDB Connection Issues?

If using MongoDB Atlas, whitelist Hugging Face IPs:

  • Go to MongoDB Atlas β†’ Network Access
  • Add IP: 0.0.0.0/0 (allow all - not recommended for production)
  • Or use specific Hugging Face egress IPs

πŸ“ File Structure for Hugging Face

.
β”œβ”€β”€ bot/                 # Telegram bot code
β”œβ”€β”€ .github/workflows/   # Auto-deploy
β”œβ”€β”€ Dockerfile           # Container config
β”œβ”€β”€ requirements.txt     # Python deps
β”œβ”€β”€ README.md            # Space docs
└── space.md             # Hugging Face config

πŸ”— Useful Links


πŸ’‘ Tips

  1. Free hosting: Hugging Face CPU Basic is free
  2. GPU encoding: Upgrade to GPU hardware for faster encoding
  3. Persistence: Hugging Face spaces are ephemeral - use MongoDB for data
  4. Sleep: Free spaces sleep after inactivity - bot will reconnect automatically

πŸŽ‰ Success!

Your bot will be live at:

https://huggingface.co/spaces/YOUR_USERNAME/anime-encoder-bot

Web admin panel:

https://huggingface.co/spaces/YOUR_USERNAME/anime-encoder-bot