Skip to content

Commit 11f36bc

Browse files
ci: push-to-ms
1 parent 8594b7b commit 11f36bc

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Push demo branch to ModelScope
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: false
8+
default: demo
9+
type: string
10+
secrets:
11+
MS_TOKEN:
12+
required: true
13+
14+
jobs:
15+
push-ms:
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: Configure Git identity
25+
run: |
26+
git config --global user.email "[email protected]"
27+
git config --global user.name "github-actions[bot]"
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
# ModelScope 官方 SDK(可选,仅当你需要调用平台 API 时才装)
33+
pip install modelscope
34+
35+
- name: Push to ModelScope
36+
env:
37+
MS_TOKEN: ${{ secrets.MS_TOKEN }}
38+
MS_REPO_TYPE: models
39+
MS_REPO_ID: chenzihong/GraphGen
40+
run: |
41+
git config --global credential.helper store
42+
echo "https://oauth2:${MS_TOKEN}@www.modelscope.cn" > ~/.git-credentials
43+
44+
[[ -d ms-repo ]] && rm -rf ms-repo
45+
git clone https://www.modelscope.cn/${MS_REPO_TYPE}/${MS_REPO_ID}.git ms-repo
46+
47+
rsync -a --delete --exclude='.git' --exclude='ms-repo' ./ ms-repo/
48+
49+
cd ms-repo
50+
git add .
51+
git diff-index --quiet HEAD || \
52+
(git commit -m "Auto-sync from ${{ inputs.ref }} at $(date -u)" && git push)

.github/workflows/sync-demo.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,10 @@ jobs:
8787
uses: ./.github/workflows/push-to-hf.yml
8888
secrets:
8989
HF_TOKEN: ${{ secrets.HF_TOKEN }}
90+
push-ms:
91+
needs: sync-demo
92+
uses: ./.github/workflows/push-to-ms.yml
93+
secrets:
94+
MS_TOKEN: ${{ secrets.MS_TOKEN }}
95+
with:
96+
ref: demo

0 commit comments

Comments
 (0)