GitHub Action
πŸš€ Auto-deploy from GitHub Actions
5a5e7a2
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 "[email protected]"
- 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:[email protected]/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