File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed
Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ sync :
2+ - source : graphgen
3+ dest : graphgen
4+ - source : resources
5+ dest : resources
6+ - source : webui
7+ dest : webui
8+ - source : webui/app.py
9+ dest : app.py
10+ - source : requirements.txt
11+ dest : requirements.txt
Original file line number Diff line number Diff line change 1+ name : Sync Demo Branch
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ workflow_dispatch :
8+
9+ jobs :
10+ sync-demo :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout main branch
15+ uses : actions/checkout@v4
16+ with :
17+ ref : main
18+ token : ${{ secrets.GITHUB_TOKEN }}
19+
20+ - name : Checkout demo branch
21+ uses : actions/checkout@v4
22+ with :
23+ ref : demo
24+ token : ${{ secrets.GITHUB_TOKEN }}
25+ path : demo
26+
27+ - name : Copy files using config
28+ run : |
29+ while IFS= read -r line; do
30+ source=$(echo $line | cut -d: -f1 | xargs)
31+ dest=$(echo $line | cut -d: -f2 | xargs)
32+
33+ if [ -e "$source" ]; then
34+ mkdir -p "demo/$(dirname $dest)"
35+ cp -r "$source" "demo/$dest"
36+ echo "Copied $source to $dest"
37+ fi
38+ done < <(grep -E '^\s*-\s+source:' .github/sync-config.yml | sed 's/.*source: //' | paste -d: - <(grep -E '^\s*-\s+dest:' .github/sync-config.yml | sed 's/.*dest: //'))
39+
40+ - name : Commit and push changes
41+ run : |
42+ cd demo
43+ git config user.name "github-actions[bot]"
44+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
45+
46+ # 检查是否有变化
47+ if [[ -n $(git status --porcelain) ]]; then
48+ git add .
49+ git commit -m "Auto-sync demo branch with main branch"
50+ git push origin demo
51+ echo "Changes pushed to demo branch"
52+ else
53+ echo "No changes to sync"
54+ fi
You can’t perform that action at this time.
0 commit comments