Skip to content

Commit 37f146f

Browse files
committed
[修改]1. 修改镜像同步为强制推送
1 parent 051f5d9 commit 37f146f

1 file changed

Lines changed: 91 additions & 55 deletions

File tree

.github/workflows/sync.yml

Lines changed: 91 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Sync Github To Image
33
on:
44
push:
55
branches: [main]
6-
#schedule:
6+
schedule:
77
# 定时任务,每天 UTC 时间 0 点运行
8-
#- cron: "0 0 * * *"
9-
#workflow_dispatch:
8+
- cron: "0 0 * * *"
9+
workflow_dispatch:
1010

1111
jobs:
1212
sync-gitlink:
@@ -49,12 +49,18 @@ jobs:
4949
run: git fetch --prune gitlink --tags --verbose
5050

5151
# 拉取
52-
- name: pull and push
52+
- name: pull
5353
run: |
5454
if [ "${{ github.ref_name }}" ]; then
5555
git checkout ${{ github.ref_name }}
5656
git pull --progress -v --no-rebase gitlink ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
57-
git push -u gitlink ${{ github.ref_name }} --tags --verbose
57+
fi
58+
59+
# 推送
60+
- name: push
61+
run: |
62+
if [ "${{ github.ref_name }}" ]; then
63+
git push -u --force gitlink ${{ github.ref_name }} --tags --verbose
5864
fi
5965
6066
sync-gitlab:
@@ -95,12 +101,18 @@ jobs:
95101
run: git fetch --prune gitlab --tags --verbose
96102

97103
# 拉取
98-
- name: pull and push
104+
- name: pull
99105
run: |
100106
if [ "${{ github.ref_name }}" ]; then
101107
git checkout ${{ github.ref_name }}
102108
git pull --progress -v --no-rebase gitlab ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
103-
git push -u gitlab ${{ github.ref_name }} --tags --verbose
109+
fi
110+
111+
# 推送
112+
- name: push
113+
run: |
114+
if [ "${{ github.ref_name }}" ]; then
115+
git push -u --force gitlab ${{ github.ref_name }} --tags --verbose
104116
fi
105117
106118
sync-gitee:
@@ -141,12 +153,18 @@ jobs:
141153
run: git fetch --prune gitee --tags --verbose
142154

143155
# 拉取
144-
- name: pull and push
156+
- name: pull
145157
run: |
146158
if [ "${{ github.ref_name }}" ]; then
147159
git checkout ${{ github.ref_name }}
148160
git pull --progress -v --no-rebase gitee ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
149-
git push -u gitee ${{ github.ref_name }} --tags --verbose
161+
fi
162+
163+
# 推送
164+
- name: push
165+
run: |
166+
if [ "${{ github.ref_name }}" ]; then
167+
git push -u --force gitee ${{ github.ref_name }} --tags --verbose
150168
fi
151169
152170
sync-atomgit:
@@ -187,59 +205,71 @@ jobs:
187205
run: git fetch --prune atomgit --tags --verbose
188206

189207
# 拉取
190-
- name: pull and push
208+
- name: pull
191209
run: |
192210
if [ "${{ github.ref_name }}" ]; then
193211
git checkout ${{ github.ref_name }}
194212
git pull --progress -v --no-rebase atomgit ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
195-
git push -u atomgit ${{ github.ref_name }} --tags --verbose
196213
fi
197214
198-
sync-gitcode:
199-
runs-on: ubuntu-latest
200-
201-
steps:
202-
- name: Checkout code
203-
uses: actions/checkout@v4
204-
with:
205-
fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
206-
207-
- name: Set up Git user
208-
run: |
209-
git config --global user.email "wangfj11@foxmail.com"
210-
git config --global user.name "AlianBlank"
211-
212-
- name: Set SSH
213-
run: |
214-
mkdir -p ~/.ssh
215-
echo "${{ secrets.GITCODE_ID_RSA }}" >> ~/.ssh/id_rsa
216-
chmod 600 ~/.ssh/id_rsa
217-
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
218-
# 信任域名
219-
ssh-keyscan -H gitcode.net >> ~/.ssh/known_hosts
220-
# 查看当前分支
221-
- name: Check current branch
222-
run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
223-
# 查看远端 地址
224-
- name: echo git url
225-
run: echo git@gitcode.net:${{ github.Repository }}.git
226-
227-
# 添加远端
228-
- name: add remote url
229-
run: git remote add gitcode "git@gitcode.net:${{ github.Repository }}.git"
230-
231-
# 获取
232-
- name: fetch
233-
run: git fetch --prune gitcode --tags --verbose
234-
235-
# 拉取
236-
- name: pull and push
215+
# 推送
216+
- name: push
237217
run: |
238218
if [ "${{ github.ref_name }}" ]; then
239-
git checkout ${{ github.ref_name }}
240-
git pull --progress -v --no-rebase gitcode ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
241-
git push -u gitcode ${{ github.ref_name }} --tags --verbose
219+
git push -u --force atomgit ${{ github.ref_name }} --tags --verbose
242220
fi
221+
222+
# sync-gitcode:
223+
# runs-on: ubuntu-latest
224+
225+
# steps:
226+
# - name: Checkout code
227+
# uses: actions/checkout@v4
228+
# with:
229+
# fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
230+
231+
# - name: Set up Git user
232+
# run: |
233+
# git config --global user.email "wangfj11@foxmail.com"
234+
# git config --global user.name "AlianBlank"
235+
236+
# - name: Set SSH
237+
# run: |
238+
# mkdir -p ~/.ssh
239+
# echo "${{ secrets.GITCODE_ID_RSA }}" >> ~/.ssh/id_rsa
240+
# chmod 600 ~/.ssh/id_rsa
241+
# eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
242+
# # 信任域名
243+
# ssh-keyscan -H gitcode.net >> ~/.ssh/known_hosts
244+
# # 查看当前分支
245+
# - name: Check current branch
246+
# run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
247+
# # 查看远端 地址
248+
# - name: echo git url
249+
# run: echo git@gitcode.net:${{ github.Repository }}.git
250+
251+
# # 添加远端
252+
# - name: add remote url
253+
# run: git remote add gitcode "git@gitcode.net:${{ github.Repository }}.git"
254+
255+
# # 获取
256+
# - name: fetch
257+
# run: git fetch --prune gitcode --tags --verbose
258+
259+
# # 拉取
260+
# - name: pull
261+
# run: |
262+
# if [ "${{ github.ref_name }}" ]; then
263+
# git checkout ${{ github.ref_name }}
264+
# git pull --progress -v --no-rebase gitcode ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
265+
# fi
266+
267+
# # 推送
268+
# - name: push
269+
# run: |
270+
# if [ "${{ github.ref_name }}" ]; then
271+
# git push -u --force gitcode ${{ github.ref_name }} --tags --verbose
272+
# fi
243273

244274
sync-framagit:
245275
runs-on: ubuntu-latest
@@ -279,10 +309,16 @@ jobs:
279309
run: git fetch --prune framagit --tags --verbose
280310

281311
# 拉取
282-
- name: pull and push
312+
- name: pull
283313
run: |
284314
if [ "${{ github.ref_name }}" ]; then
285315
git checkout ${{ github.ref_name }}
286316
git pull --progress -v --no-rebase framagit ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
287-
git push -u framagit ${{ github.ref_name }} --tags --verbose
317+
fi
318+
319+
# 推送
320+
- name: push
321+
run: |
322+
if [ "${{ github.ref_name }}" ]; then
323+
git push -u --force framagit ${{ github.ref_name }} --tags --verbose
288324
fi

0 commit comments

Comments
 (0)