Skip to content

Commit 146f3b3

Browse files
ci: auto push demo to hf
1 parent 240b169 commit 146f3b3

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

.github/sync-config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ sync:
99
dest: app.py
1010
- source: requirements.txt
1111
dest: requirements.txt
12+
- source: README.md
13+
dest: README.md
14+
- source: README_ZH.md
15+
dest: README_ZH.md
16+
- source: LICENSE
17+
dest: LICENSE

.github/workflows/push-to-hf.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Push demo branch to Hugging Face
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: false
8+
default: demo
9+
type: string
10+
secrets:
11+
HF_TOKEN:
12+
required: true
13+
14+
jobs:
15+
push-hf:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{ inputs.ref }}
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install huggingface_hub
28+
29+
- name: Push to Hugging Face
30+
env:
31+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
32+
HF_REPO_TYPE: space
33+
HF_REPO_ID: chenzihong/GraphGen
34+
run: |
35+
huggingface-cli login --token "$HF_TOKEN" --add-to-git-credential
36+
git clone https://huggingface.co/$HF_REPO_TYPE/$HF_REPO_ID hf-repo
37+
rsync -a --delete --exclude='.git' ./ hf-repo/
38+
cd hf-repo
39+
git add .
40+
git diff-index --quiet HEAD || (git commit -m "Auto-sync from ${{ inputs.ref }} at $(date -u)" && git push)

.github/workflows/sync-demo.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ jobs:
6868
else
6969
echo "No changes to sync"
7070
fi
71+
72+
push-hf:
73+
needs: sync-demo
74+
uses: ./.github/workflows/push-to-hf.yml
75+
secrets:
76+
HF_TOKEN: ${{ secrets.HF_TOKEN }}

0 commit comments

Comments
 (0)