creatorplus / DEPLOYMENT_HF.md
nitubhai's picture
Upload 13 files
0a512d5 verified

Deployment Guide for Hugging Face Spaces

Prerequisites

  1. Hugging Face account (free)
  2. GitHub repository with your code
  3. Google Cloud OAuth credentials (client_secret.json)
  4. Required API keys:
    • Google Gemini API key
    • Instagram session ID

Step 1: Prepare Google Cloud OAuth

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable YouTube Data API v3
  4. Go to Credentials β†’ Create OAuth 2.0 Client ID
  5. Choose Web application
  6. Add authorized redirect URI:
    https://YOUR_USERNAME-youtube-automation-studio.hf.space/auth/callback
    
  7. Download client_secret.json

Step 2: Get Instagram Session ID

  1. Open Instagram in Chrome browser
  2. Login to your Instagram account
  3. Press F12 (Developer Tools)
  4. Go to Application tab β†’ Cookies β†’ https://instagram.com
  5. Find cookie named sessionid
  6. Copy the entire value (should be 40+ characters)

Step 3: Generate Secret Key

Run this Python command:

python -c "import secrets; print(secrets.token_hex(32))"

Copy the output.

Step 4: Create Hugging Face Space

  1. Go to https://huggingface.co/spaces
  2. Click Create new Space
  3. Fill in details:
    • Space name: youtube-automation-studio
    • License: MIT
    • Select SDK: Docker
    • Space hardware: CPU basic (free)
  4. Click Create Space

Step 5: Configure Environment Variables

In your Space settings β†’ Variables and secrets:

Add these secrets:

ENVIRONMENT=production
GEMINI_API_KEY=your-gemini-api-key-from-google-ai-studio
IG_SESSIONID=your-instagram-sessionid-from-cookies
SECRET_KEY=your-generated-secret-key-from-step3

Step 6: Upload client_secret.json

In your Space β†’ Files tab:

  1. Click Add file β†’ Upload files
  2. Upload your client_secret.json
  3. Mark it as secret file if option available

Step 7: Push Code to Hugging Face

Option A: Direct Git Push

# Clone your HF Space repository
git clone https://huggingface.co/spaces/YOUR_USERNAME/youtube-automation-studio
cd youtube-automation-studio

# Copy all your project files
cp -r /path/to/your/project/* .

# Make sure these files are present:
# - Dockerfile
# - requirements.txt
# - app.py
# - All other Python files
# - templates/ folder
# - static/ folder
# - client_secret.json (if not uploaded via UI)

# Commit and push
git add .
git commit -m "Initial deployment"
git push

Option B: Via GitHub

If your code is on GitHub:

  1. In your HF Space settings
  2. Go to Files and versions β†’ Settings
  3. Connect to GitHub repository
  4. Select branch to deploy from

Step 8: Wait for Build

  • Build typically takes 5-10 minutes
  • Monitor logs in Logs tab
  • Check for any errors

Step 9: Test Your Deployment

  1. Once build completes, visit your Space URL:

    https://YOUR_USERNAME-youtube-automation-studio.hf.space
    
  2. Test each feature:

    • βœ… Homepage loads
    • βœ… Sign in with YouTube works
    • βœ… Download Instagram Reel
    • βœ… AI metadata generation
    • βœ… Video upload to YouTube

Step 10: Update OAuth Redirect URI (If Needed)

If authentication fails:

  1. Go back to Google Cloud Console
  2. Edit your OAuth 2.0 Client
  3. Verify redirect URI matches exactly:
    https://YOUR_USERNAME-youtube-automation-studio.hf.space/auth/callback
    
  4. Save and wait 5 minutes for changes to propagate

Monitoring & Maintenance

Check Logs