anurag008w commited on
Commit
10c5754
·
unverified ·
1 Parent(s): 4f21603

Add workflow to sync from Hugging Face Space to GitHub

Browse files

This workflow automates the synchronization of files from a private Hugging Face Space to a GitHub repository, including setup for Git LFS and handling of changes.

Files changed (1) hide show
  1. .github/workflows/sync-from-hf.yml +66 -0
.github/workflows/sync-from-hf.yml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync Hugging Face Space to GitHub
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: write
8
+
9
+ jobs:
10
+ sync-from-hf:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout GitHub Repo
15
+ uses: actions/checkout@v4
16
+ with:
17
+ token: ${{ secrets.GH_PAT }}
18
+ fetch-depth: 0
19
+
20
+ - name: Install Git LFS
21
+ run: |
22
+ sudo apt-get update
23
+ sudo apt-get install -y git-lfs rsync
24
+ git lfs install
25
+
26
+ - name: Clone Private Hugging Face Space
27
+ env:
28
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
29
+ run: |
30
+ rm -rf /tmp/hf-space
31
+
32
+ git clone \
33
+ https://oauth2:${HF_TOKEN}@huggingface.co/spaces/anuragwa022/HuggingClaw \
34
+ /tmp/hf-space
35
+
36
+ - name: Sync Files
37
+ run: |
38
+ shopt -s dotglob
39
+
40
+ rsync -av --delete \
41
+ --exclude=".git" \
42
+ --exclude=".github" \
43
+ --exclude=".cache" \
44
+ --exclude="node_modules" \
45
+ --exclude="*.bin" \
46
+ --exclude="*.safetensors" \
47
+ --exclude="*.gguf" \
48
+ /tmp/hf-space/ ./
49
+
50
+ - name: Commit Changes
51
+ run: |
52
+ git config user.name "github-actions[bot]"
53
+ git config user.email "github-actions[bot]@users.noreply.github.com"
54
+
55
+ git add -A
56
+
57
+ if git diff --cached --quiet; then
58
+ echo "No changes detected"
59
+ exit 0
60
+ fi
61
+
62
+ git commit -m "sync: update from private huggingface space"
63
+
64
+ - name: Push Changes
65
+ run: |
66
+ git push origin HEAD