# 🚀 Deploy to GitHub + Hugging Face ## Quick Start ### 1. Initialize & Push to GitHub **Windows:** ```cmd setup-github.bat ``` **Linux/Mac:** ```bash bash setup-github.sh ``` ### 2. Manual GitHub Push ```bash # 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):** ```bash push-hf.bat ``` Enter your space ID when prompted. ### 5. Hugging Face Environment Variables In your Space, go to **Settings > Variables**: ```env 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? ```bash 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 - **GitHub**: https://github.com/new - **Hugging Face Tokens**: https://huggingface.co/settings/tokens - **New Space**: https://huggingface.co/new-space - **HF Docker Docs**: https://huggingface.co/docs/hub/spaces-sdks-docker --- ## 💡 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 ```