-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (31 loc) · 1.14 KB
/
sync-from-gitee.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Sync from Gitee
on:
workflow_dispatch:
schedule:
- cron: '20 5 * * *' # UTC时区; 每天执行一次
jobs:
sync:
if: github.ref == 'refs/heads/main' # 仅当在main分支上时才执行
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pull changes from Gitee
run: |
git remote add gitee https://gitee.com/we-mid/go.git
git fetch gitee main
# 判断某个远端分支,相比与当前本地分支是否存在ahead提交
if git rev-list main..gitee/main | grep -q .; then
echo "ahead"
# fix: Committer identity unknown
git config user.email "[email protected]"
git config user.name "GitHub Actions"
# 避免额外提交: Merge remote-tracking branch 'xx/xxx'
# git merge gitee/main --allow-unrelated-histories
# git push origin main
# 使用 rebase 而不是 merge
git rebase gitee/main
git push origin main --force-with-lease
else
echo "not ahead"
echo "skip"
fi