Skip to content

Commit b4e76c8

Browse files
Update GitHub Actions workflow for Hugging Face sync
1 parent 2ac8641 commit b4e76c8

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

.github/workflows/sync_to_hf.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
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

0 commit comments

Comments
 (0)