-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (64 loc) · 2.52 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Sync Repository
on:
schedule:
# 每周一下午6点(UTC时间)执行,对应中国东八区凌晨2点
- cron: "0 18 * * *"
workflow_dispatch:
inputs:
targetRepo:
description: "Target repository"
required: true
default: "jagger235711/HB"
targetBranch1:
description: "Target branch 1"
required: true
default: "Routines"
upstreamRepo1:
description: "Upstream repository 1"
required: true
default: "UniverseString/Hearthstone-myRoutines"
upstreamBranch1:
description: "Upstream branch 1"
required: true
default: "master"
gitUserName:
description: "Git user name"
required: true
default: "mergeBot"
gitUserEmail:
description: "Git user email"
required: true
default: "[email protected]"
env:
DEFAULT_TARGET_REPO: "jagger235711/HB"
DEFAULT_TARGET_BRANCH1: "Routines"
DEFAULT_UPSTREAM_REPO1: "UniverseString/Hearthstone-myRoutines"
DEFAULT_UPSTREAM_BRANCH1: "master"
DEFAULT_GIT_USER_NAME: "mergeBot"
DEFAULT_GIT_USER_EMAIL: "[email protected]"
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN_EE }} # 使用单个 Token
jobs:
sync-branch1:
runs-on: ubuntu-latest
env:
TZ: Asia/Shanghai
steps:
- name: Checkout target repository for branch 1
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.targetRepo || env.DEFAULT_TARGET_REPO }}
ref: ${{ github.event.inputs.targetBranch1 || env.DEFAULT_TARGET_BRANCH1 }}
token: ${{ secrets.REPO_ACCESS_TOKEN }} # 使用单个 Token
- name: Setup Git
run: |
git config --global user.name "${{ github.event.inputs.gitUserName || env.DEFAULT_GIT_USER_NAME }}"
git config --global user.email "${{ github.event.inputs.gitUserEmail || env.DEFAULT_GIT_USER_EMAIL }}"
- name: Verify timezone
run: date
- name: Add and merge changes from upstream repository 1 to branch 1
run: |
git remote add upstream1 https://x-access-token:${REPO_ACCESS_TOKEN}@gitee.com/${{ github.event.inputs.upstreamRepo1 || env.DEFAULT_UPSTREAM_REPO1 }}.git
git fetch upstream1
git checkout ${{ github.event.inputs.targetBranch1 || env.DEFAULT_TARGET_BRANCH1 }}
git reset --hard upstream1/${{ github.event.inputs.upstreamBranch1 || env.DEFAULT_UPSTREAM_BRANCH1 }}
git push origin ${{ github.event.inputs.targetBranch1 || env.DEFAULT_TARGET_BRANCH1 }} --force