Skip to content

Commit 8be8da8

Browse files
Merge pull request #54 from open-sciencelab/push-to-ms
ci: push-to-ms
2 parents 8594b7b + b83b525 commit 8be8da8

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 official SDK (optional, install only if you need to call the platform 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+
# Use token in the clone URL, do not write credentials to disk
42+
[[ -d ms-repo ]] && rm -rf ms-repo
43+
git clone https://oauth2:${MS_TOKEN}@www.modelscope.cn/${MS_REPO_TYPE}/${MS_REPO_ID}.git ms-repo
44+
45+
rsync -a --delete --exclude='.git' --exclude='ms-repo' ./ ms-repo/
46+
47+
cd ms-repo
48+
git add .
49+
git diff-index --quiet HEAD || \
50+
(git commit -m "Auto-sync from ${{ inputs.ref }} at $(date -u)" && \
51+
git push "https://oauth2:${MS_TOKEN}@www.modelscope.cn/${MS_REPO_TYPE}/${MS_REPO_ID}.git")

.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)