Skip to content

Commit 31e7054

Browse files
committed
fix: 修复版本tag异常的工作流
1 parent c41cac2 commit 31e7054

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

.github/workflows/sync.yml

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
name: Sync Github To Image
22

33
on:
4+
workflow_run:
5+
workflows: ["Publish Release"] # 监听的工作流名称
6+
types:
7+
- completed # 监听完成事件
48
push:
59
branches: [main]
610
#schedule:
711
# 定时任务,每天 UTC 时间 0 点运行
812
#- cron: "0 0 * * *"
9-
#workflow_dispatch:
13+
workflow_dispatch:
14+
1015

1116
jobs:
1217
sync-gitlink:
@@ -42,21 +47,22 @@ jobs:
4247

4348
# 添加远端
4449
- name: add remote url
45-
run: git remote add gitlink "[email protected]:${{ github.Repository }}.git"
50+
run: git remote add mirror "[email protected]:${{ github.Repository }}.git"
4651

4752
# 获取
4853
- name: fetch
49-
run: git fetch --prune gitlink --tags --verbose
54+
run: git fetch --prune mirror --tags --verbose
5055

51-
# 拉取
56+
# 拉取和推送
5257
- name: pull and push
5358
run: |
5459
if [ "${{ github.ref_name }}" ]; then
5560
git checkout ${{ github.ref_name }}
56-
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
61+
git push -f mirror ${{ github.ref_name }}
62+
git push -f mirror --tags --verbose
5863
fi
5964
65+
6066
sync-gitlab:
6167
runs-on: ubuntu-latest
6268

@@ -88,21 +94,22 @@ jobs:
8894

8995
# 添加远端
9096
- name: add remote url
91-
run: git remote add gitlab "[email protected]:${{ github.Repository }}.git"
97+
run: git remote add mirror "[email protected]:${{ github.Repository }}.git"
9298

9399
# 获取
94100
- name: fetch
95-
run: git fetch --prune gitlab --tags --verbose
101+
run: git fetch --prune mirror --tags --verbose
96102

97-
# 拉取
103+
# 拉取和推送
98104
- name: pull and push
99105
run: |
100106
if [ "${{ github.ref_name }}" ]; then
101107
git checkout ${{ github.ref_name }}
102-
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
108+
git push -f mirror ${{ github.ref_name }}
109+
git push -f mirror --tags --verbose
104110
fi
105111
112+
106113
sync-gitee:
107114
runs-on: ubuntu-latest
108115

@@ -134,21 +141,22 @@ jobs:
134141

135142
# 添加远端
136143
- name: add remote url
137-
run: git remote add gitee "[email protected]:${{ github.Repository }}.git"
144+
run: git remote add mirror "[email protected]:${{ github.Repository }}.git"
138145

139146
# 获取
140147
- name: fetch
141-
run: git fetch --prune gitee --tags --verbose
148+
run: git fetch --prune mirror --tags --verbose
142149

143-
# 拉取
150+
# 拉取和推送
144151
- name: pull and push
145152
run: |
146153
if [ "${{ github.ref_name }}" ]; then
147154
git checkout ${{ github.ref_name }}
148-
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
155+
git push -f mirror ${{ github.ref_name }}
156+
git push -f mirror --tags --verbose
150157
fi
151158
159+
152160
sync-atomgit:
153161
runs-on: ubuntu-latest
154162

@@ -180,21 +188,22 @@ jobs:
180188

181189
# 添加远端
182190
- name: add remote url
183-
run: git remote add atomgit "[email protected]:${{ github.Repository }}.git"
191+
run: git remote add mirror "[email protected]:${{ github.Repository }}.git"
184192

185193
# 获取
186194
- name: fetch
187-
run: git fetch --prune atomgit --tags --verbose
195+
run: git fetch --prune mirror --tags --verbose
188196

189-
# 拉取
197+
# 拉取和推送
190198
- name: pull and push
191199
run: |
192200
if [ "${{ github.ref_name }}" ]; then
193201
git checkout ${{ github.ref_name }}
194-
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
202+
git push -f mirror ${{ github.ref_name }}
203+
git push -f mirror --tags --verbose
196204
fi
197205
206+
198207
sync-gitcode:
199208
runs-on: ubuntu-latest
200209

@@ -226,20 +235,21 @@ jobs:
226235

227236
# 添加远端
228237
- name: add remote url
229-
run: git remote add gitcode "[email protected]:${{ github.Repository }}.git"
238+
run: git remote add mirror "[email protected]:${{ github.Repository }}.git"
230239

231240
# 获取
232241
- name: fetch
233-
run: git fetch --prune gitcode --tags --verbose
242+
run: git fetch --prune mirror --tags --verbose
234243

235-
# 拉取
244+
# 拉取和推送
236245
- name: pull and push
237246
run: |
238247
if [ "${{ github.ref_name }}" ]; then
239248
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
249+
git push -f mirror ${{ github.ref_name }}
250+
git push -f mirror --tags --verbose
242251
fi
252+
243253
244254
sync-framagit:
245255
runs-on: ubuntu-latest
@@ -272,17 +282,17 @@ jobs:
272282

273283
# 添加远端
274284
- name: add remote url
275-
run: git remote add framagit "[email protected]:${{ github.Repository }}.git"
285+
run: git remote add mirror "[email protected]:${{ github.Repository }}.git"
276286

277287
# 获取
278288
- name: fetch
279-
run: git fetch --prune framagit --tags --verbose
289+
run: git fetch --prune mirror --tags --verbose
280290

281-
# 拉取
291+
# 拉取和推送
282292
- name: pull and push
283293
run: |
284294
if [ "${{ github.ref_name }}" ]; then
285295
git checkout ${{ github.ref_name }}
286-
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
296+
git push -f mirror ${{ github.ref_name }}
297+
git push -f mirror --tags --verbose
288298
fi

0 commit comments

Comments
 (0)