name: 🚀 Deploy to Hugging Face Space on: push: branches: [ main, master ] pull_request: branches: [ main, master ] workflow_dispatch: # Manual trigger jobs: deploy: runs-on: ubuntu-latest steps: - name: 🔍 Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 lfs: true - name: 🐍 Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' - name: 📦 Install dependencies run: | python -m pip install --upgrade pip pip install huggingface_hub if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: 🔧 Configure Git for HF run: | git config --global user.name "GitHub Actions" git config --global user.email "actions@github.com" - name: 📊 Check for important files run: | echo "🔍 Checking workspace contents..." ls -la echo "📔 Jupyter Notebooks:" find . -name "*.ipynb" -type f echo "🐍 Python files:" find . -name "*.py" -type f | head -10 echo "📄 Documentation:" find . -name "*.md" -type f | head -5 - name: 🚀 Deploy to Hugging Face Space env: HF_TOKEN: ${{ secrets.HF_TOKEN }} HF_REPO: kenken999/fastapi_django_main_live run: | echo "🔐 Setting up Hugging Face authentication..." if [ -z "$HF_TOKEN" ]; then echo "❌ HF_TOKEN secret not found!" echo "Please add your Hugging Face token to GitHub Secrets" exit 1 fi # Clone HF repo echo "📥 Cloning Hugging Face Space..." git clone https://kenken999:$HF_TOKEN@huggingface.co/spaces/$HF_REPO hf_repo cd hf_repo # Copy important files echo "📋 Copying files to HF repo..." # Core system files cp -f ../system_workflow_analysis.ipynb . || echo "Notebook not found" cp -f ../app.py . || echo "App.py not found" cp -f ../generate_prompt.py . || echo "Generate prompt not found" cp -f ../screenshot_capture.py . || echo "Screenshot capture not found" cp -f ../requirements.txt . || echo "Requirements not found" cp -f ../README.md . || echo "README not found" # Copy controllers directory if [ -d "../controllers" ]; then echo "📁 Copying controllers directory..." cp -rf ../controllers . || echo "Controllers copy failed" fi # Copy routers directory if [ -d "../routers" ]; then echo "📁 Copying routers directory..." cp -rf ../routers . || echo "Routers copy failed" fi # Check what we're about to commit echo "📊 Git status before commit:" git status # Add and commit changes git add . if git diff --cached --quiet; then echo "✅ No changes to commit" else echo "💾 Committing changes..." git commit -m "🚀 Auto-deploy from GitHub Actions Deployed from: ${{ github.repository }} Commit: ${{ github.sha }} Branch: ${{ github.ref_name }} Workflow: ${{ github.workflow }} Updated files: - System workflow analysis notebook - Core Python modules - Controllers and routers - Documentation and configs" echo "📤 Pushing to Hugging Face Space..." git push origin main echo "✅ Successfully deployed to Hugging Face Space!" echo "🌐 View at: https://huggingface.co/spaces/$HF_REPO" fi - name: 📝 Deployment Summary if: always() run: | echo "## 🎯 Deployment Summary" >> $GITHUB_STEP_SUMMARY echo "- **Repository:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY echo "- **Hugging Face Space:** https://huggingface.co/spaces/kenken999/fastapi_django_main_live" >> $GITHUB_STEP_SUMMARY echo "- **Jupyter Notebook:** https://huggingface.co/spaces/kenken999/fastapi_django_main_live/blob/main/system_workflow_analysis.ipynb" >> $GITHUB_STEP_SUMMARY