File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Sync Github To Image
2+
3+ on :
4+ push :
5+ branches : [main]
6+ # schedule:
7+ # 定时任务,每天 UTC 时间 0 点运行
8+ # - cron: "0 0 * * *"
9+ workflow_dispatch :
10+
11+ jobs :
12+ sync-gitee :
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
20+
21+ - name : Set up Git user
22+ run : |
23+ git config --global user.email "wangfj11@foxmail.com"
24+ git config --global user.name "AlianBlank"
25+
26+ - name : Set SSH
27+ run : |
28+ mkdir -p ~/.ssh
29+ echo "${{ secrets.GITEE_ID_RSA }}" >> ~/.ssh/id_rsa
30+ chmod 600 ~/.ssh/id_rsa
31+ eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
32+ # 信任域名
33+ ssh-keyscan -H gitee.com >> ~/.ssh/known_hosts
34+ # 查看当前分支
35+ - name : Check current branch
36+ run : echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
37+ # 查看远端 地址
38+ - name : echo git url
39+ run : echo git@gitee.com:${{ github.Repository }}.git
40+
41+ # 添加远端
42+ - name : add remote url
43+ run : git remote add mirror "git@gitee.com:${{ github.Repository }}.git"
44+
45+ # 获取
46+ - name : fetch
47+ run : git fetch --prune mirror --tags --verbose
48+
49+ # 拉取和推送
50+ - name : pull and push
51+ run : |
52+ if [ "${{ github.ref_name }}" ]; then
53+ git checkout ${{ github.ref_name }}
54+ git push -f mirror ${{ github.ref_name }}
55+ git push -f mirror --tags --verbose
56+ fi
You can’t perform that action at this time.
0 commit comments