File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed
Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Sync Upstream
2+
3+ on :
4+ schedule :
5+ # 每天 UTC 0:00 检查上游更新
6+ - cron : ' 0 0 * * *'
7+ workflow_dispatch :
8+ inputs :
9+ sync_method :
10+ description : ' 同步方式'
11+ required : true
12+ default : ' rebase'
13+ type : choice
14+ options :
15+ - rebase
16+ - merge
17+
18+ jobs :
19+ sync :
20+ runs-on : ubuntu-latest
21+ steps :
22+ - name : Checkout
23+ uses : actions/checkout@v4
24+ with :
25+ fetch-depth : 0
26+ token : ${{ secrets.GITHUB_TOKEN }}
27+
28+ - name : Setup Git
29+ run : |
30+ git config user.name "github-actions[bot]"
31+ git config user.email "github-actions[bot]@users.noreply.github.com"
32+
33+ - name : Add upstream
34+ run : |
35+ git remote add upstream https://github.com/wyx2685/v2node.git
36+ git fetch upstream
37+
38+ - name : Check for updates
39+ id : check
40+ run : |
41+ UPSTREAM_COMMITS=$(git rev-list HEAD..upstream/main --count)
42+ echo "upstream_commits=$UPSTREAM_COMMITS" >> $GITHUB_OUTPUT
43+ if [ "$UPSTREAM_COMMITS" -gt 0 ]; then
44+ echo "有 $UPSTREAM_COMMITS 个新提交需要同步"
45+ else
46+ echo "上游没有新提交"
47+ fi
48+
49+ - name : Sync upstream (rebase)
50+ if : steps.check.outputs.upstream_commits > 0 && (github.event.inputs.sync_method == 'rebase' || github.event_name == 'schedule')
51+ run : |
52+ git rebase upstream/main
53+ git push --force-with-lease
54+
55+ - name : Sync upstream (merge)
56+ if : steps.check.outputs.upstream_commits > 0 && github.event.inputs.sync_method == 'merge'
57+ run : |
58+ git merge upstream/main -m "chore: 同步上游更新"
59+ git push
You can’t perform that action at this time.
0 commit comments