GitHub Action
Sync from GitHub Actions (Clean Commit)
7f22d3c
name: Sync to Hugging Face hub
on:
push:
branches: [main] # 当推送到 main 分支时触发
# 允许手动触发 (Workflow Dispatch)
workflow_dispatch:
jobs:
sync-to-hub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # 必须拉取完整的 git 历史记录
lfs: true # 如果你有大文件,开启 LFS (Large File Storage)
- name: Push to hub
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }} # 引用刚才设置的 Secret
# 下面替换成你的 Hugging Face 用户名和 Space 名称
HF_USERNAME: "YuanhaoChen"
HF_SPACE_NAME: "SmartPagerankSearch"
run: |
# 配置 git 用户
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
# 强制创建一个全新的 orphan 分支,不包含任何历史记录
git checkout --orphan hf-sync-branch
# Remove any potential binary files that might have been checked out or generated
rm -f visual_rank_engine.so
find . -name "*.so" -type f -delete
rm -rf visual_rank_engine/target
git add .
git commit -m "Sync from GitHub Actions (Clean Commit)"
git remote add space https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$HF_SPACE_NAME
git push --force space hf-sync-branch:main