anurag008w commited on
Commit
ded7d74
·
unverified ·
1 Parent(s): 3999915

Add GitHub Actions workflow to sync with HF Space

Browse files

This workflow automates the process of syncing a GitHub repository with a Hugging Face Space, including steps for checking out the repo, installing dependencies, cloning the HF Space, syncing files, and pushing changes.

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