|
name: π Deploy to Hugging Face Space |
|
|
|
on: |
|
push: |
|
branches: [ main, master ] |
|
pull_request: |
|
branches: [ main, master ] |
|
workflow_dispatch: |
|
|
|
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 |
|
|
|
|
|
echo "π₯ Cloning Hugging Face Space..." |
|
git clone https://kenken999:[email protected]/spaces/$HF_REPO hf_repo |
|
cd hf_repo |
|
|
|
|
|
echo "π Copying files to HF repo..." |
|
|
|
|
|
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" |
|
|
|
|
|
if [ -d "../controllers" ]; then |
|
echo "π Copying controllers directory..." |
|
cp -rf ../controllers . || echo "Controllers copy failed" |
|
fi |
|
|
|
|
|
if [ -d "../routers" ]; then |
|
echo "π Copying routers directory..." |
|
cp -rf ../routers . || echo "Routers copy failed" |
|
fi |
|
|
|
|
|
echo "π Git status before commit:" |
|
git status |
|
|
|
|
|
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 |
|
|