| name: Sync to Hugging Face hub | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| sync-to-hub: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Push to hub | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| # 1. 配置身份 | |
| git config --global user.email "bot@github.com" | |
| git config --global user.name "GitHub Action" | |
| # 2. 彻底移除二进制文件及其索引 | |
| rm -rf generated_images | |
| git rm -r --cached generated_images || echo "Already removed" | |
| # 3. 创建一个全新的、没有历史记录的临时分支 | |
| git checkout --orphan temp-branch | |
| # 4. 只添加当前的代码文件 | |
| git add . | |
| git commit -m "Deploy clean version of Nora" | |
| # 5. 强制推送到 Hugging Face 的 main 分支 | |
| # 注意:这会覆盖 HF 上的所有历史,非常适合解决当前死锁 | |
| git push --force https://kernel14:$HF_TOKEN@huggingface.co/spaces/kernel14/Nora temp-branch:main | |