-
Notifications
You must be signed in to change notification settings - Fork 249
43 lines (38 loc) · 1.28 KB
/
sync.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
37
38
39
40
41
42
43
name: Sync Fork
on:
schedule:
- cron: '0 0 * * *' # 每天运行一次
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git
run: |
git remote add upstream https://github.com/yoyodadada/haoruanfenxiang.git
# 获取上游仓库 URL
UPSTREAM_URL=$(git remote get-url upstream)
# 获取当前仓库 URL
ORIGIN_URL=$(git remote get-url origin)
echo "Upstream URL: $UPSTREAM_URL"
echo "Origin URL: $ORIGIN_URL"
# 检查是否相同,并设置环境变量
if [ "$UPSTREAM_URL" = "$ORIGIN_URL" ]; then
echo "Skipping sync because the upstream is the same as origin."
echo "SKIP_SYNC=true" >> $GITHUB_ENV
else
echo "SKIP_SYNC=false" >> $GITHUB_ENV
fi
- name: Fetch and Merge Upstream
if: env.SKIP_SYNC != 'true'
run: |
git fetch upstream
git checkout main
git merge upstream/main --allow-unrelated-histories
- name: Push Changes
if: env.SKIP_SYNC != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin main