# GitHub Actions 自动部署到 Hugging Face Spaces # # 使用方法: # 1. 在 GitHub 仓库 Settings → Secrets → Actions 中添加: # - HF_TOKEN: 你的 Hugging Face API Token (Write 权限) # 2. 修改下面的仓库地址为你的 Space 地址 # 3. 推送代码到 main 分支,自动触发部署 name: Deploy to Hugging Face Spaces on: push: branches: [main] workflow_dispatch: jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies run: | pip install -r requirements.txt - name: Syntax check run: | python -m py_compile app.py - name: Deploy to Hugging Face Spaces env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | # 安装 huggingface_hub CLI pip install -q huggingface-hub # 登录 HF huggingface-cli login --token $HF_TOKEN # 克隆 Space 仓库(替换为你的 Space 地址) # 格式: https://huggingface.co/spaces/{username}/{space-name} # git clone https://huggingface.co/spaces/your-username/florenceforge-webui space-repo # 复制文件到 Space 目录 # cp -r app.py requirements.txt Dockerfile README.md space-repo/ # cd space-repo # 提交并推送 # git add . # git commit -m "Auto-deploy from GitHub Actions" # git push echo "Deployment configured. Uncomment the git commands above after setting your Space URL."