File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- - name : Push to Hub
1+ name : Sync to Hugging Face Hub
2+
3+ on :
4+ push :
5+ branches : [main]
6+ workflow_dispatch :
7+
8+ jobs :
9+ sync-to-hub :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout Code
13+ uses : actions/checkout@v4
14+ with :
15+ fetch-depth : 0
16+ lfs : true
17+
18+ - name : Push to Hub
219 env :
320 HF_TOKEN : ${{ secrets.HF_TOKEN }}
421 run : |
5- # 1. Remove the docs folder from the local temporary sync
22+ # 1. Create a temporary branch so we don't mess with the local state
23+ git checkout -b hf-sync-branch
24+
25+ # 2. Remove the docs folder (and any other large files) for the Space
26+ # This keeps the images out of the HF Git history
627 rm -rf docs/
728
8- # 2. Commit the deletion locally so Git knows they are gone
29+ # 3. Configure git and commit the deletions on this temporary branch
930 git config user.name github-actions
1031 git config user.email github-actions@github.com
1132 git add .
12- git commit -m "Remove docs for HF sync" || echo "No docs to remove "
33+ git commit -m "Cleanup binary files for Hugging Face sync" || echo "No changes to commit "
1334
14- # 3. Push to Hugging Face
15- git push -f https://asksunny:$HF_TOKEN@huggingface.co/spaces/asksunny/Compileo main
35+ # 4. Force push the temporary branch to the HF 'main' branch
36+ # Format: git push -f https://<username>:<token>@huggingface.co/spaces/<user>/<space> <local-branch>:<remote-branch>
37+ git push -f https://asksunny:$HF_TOKEN@huggingface.co/spaces/asksunny/Compileo hf-sync-branch:main
You can’t perform that action at this time.
0 commit comments