|
1 | 1 | name: Sync Github To Image |
2 | 2 |
|
3 | 3 | on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Publish Release"] # 监听的工作流名称 |
| 6 | + types: |
| 7 | + - completed # 监听完成事件 |
4 | 8 | push: |
5 | 9 | branches: [main] |
6 | 10 | #schedule: |
7 | 11 | # 定时任务,每天 UTC 时间 0 点运行 |
8 | 12 | #- cron: "0 0 * * *" |
9 | | - #workflow_dispatch: |
| 13 | + workflow_dispatch: |
| 14 | + |
10 | 15 |
|
11 | 16 | jobs: |
12 | 17 | sync-gitlink: |
@@ -42,21 +47,22 @@ jobs: |
42 | 47 |
|
43 | 48 | # 添加远端 |
44 | 49 | - 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" |
46 | 51 |
|
47 | 52 | # 获取 |
48 | 53 | - name: fetch |
49 | | - run: git fetch --prune gitlink --tags --verbose |
| 54 | + run: git fetch --prune mirror --tags --verbose |
50 | 55 |
|
51 | | - # 拉取 |
| 56 | + # 拉取和推送 |
52 | 57 | - name: pull and push |
53 | 58 | run: | |
54 | 59 | if [ "${{ github.ref_name }}" ]; then |
55 | 60 | 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 |
58 | 63 | fi |
59 | 64 |
|
| 65 | +
|
60 | 66 | sync-gitlab: |
61 | 67 | runs-on: ubuntu-latest |
62 | 68 |
|
@@ -88,21 +94,22 @@ jobs: |
88 | 94 |
|
89 | 95 | # 添加远端 |
90 | 96 | - 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" |
92 | 98 |
|
93 | 99 | # 获取 |
94 | 100 | - name: fetch |
95 | | - run: git fetch --prune gitlab --tags --verbose |
| 101 | + run: git fetch --prune mirror --tags --verbose |
96 | 102 |
|
97 | | - # 拉取 |
| 103 | + # 拉取和推送 |
98 | 104 | - name: pull and push |
99 | 105 | run: | |
100 | 106 | if [ "${{ github.ref_name }}" ]; then |
101 | 107 | 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 |
104 | 110 | fi |
105 | 111 |
|
| 112 | +
|
106 | 113 | sync-gitee: |
107 | 114 | runs-on: ubuntu-latest |
108 | 115 |
|
@@ -134,21 +141,22 @@ jobs: |
134 | 141 |
|
135 | 142 | # 添加远端 |
136 | 143 | - 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" |
138 | 145 |
|
139 | 146 | # 获取 |
140 | 147 | - name: fetch |
141 | | - run: git fetch --prune gitee --tags --verbose |
| 148 | + run: git fetch --prune mirror --tags --verbose |
142 | 149 |
|
143 | | - # 拉取 |
| 150 | + # 拉取和推送 |
144 | 151 | - name: pull and push |
145 | 152 | run: | |
146 | 153 | if [ "${{ github.ref_name }}" ]; then |
147 | 154 | 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 |
150 | 157 | fi |
151 | 158 |
|
| 159 | +
|
152 | 160 | sync-atomgit: |
153 | 161 | runs-on: ubuntu-latest |
154 | 162 |
|
@@ -180,21 +188,22 @@ jobs: |
180 | 188 |
|
181 | 189 | # 添加远端 |
182 | 190 | - 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" |
184 | 192 |
|
185 | 193 | # 获取 |
186 | 194 | - name: fetch |
187 | | - run: git fetch --prune atomgit --tags --verbose |
| 195 | + run: git fetch --prune mirror --tags --verbose |
188 | 196 |
|
189 | | - # 拉取 |
| 197 | + # 拉取和推送 |
190 | 198 | - name: pull and push |
191 | 199 | run: | |
192 | 200 | if [ "${{ github.ref_name }}" ]; then |
193 | 201 | 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 |
196 | 204 | fi |
197 | 205 |
|
| 206 | +
|
198 | 207 | sync-gitcode: |
199 | 208 | runs-on: ubuntu-latest |
200 | 209 |
|
@@ -226,20 +235,21 @@ jobs: |
226 | 235 |
|
227 | 236 | # 添加远端 |
228 | 237 | - 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" |
230 | 239 |
|
231 | 240 | # 获取 |
232 | 241 | - name: fetch |
233 | | - run: git fetch --prune gitcode --tags --verbose |
| 242 | + run: git fetch --prune mirror --tags --verbose |
234 | 243 |
|
235 | | - # 拉取 |
| 244 | + # 拉取和推送 |
236 | 245 | - name: pull and push |
237 | 246 | run: | |
238 | 247 | if [ "${{ github.ref_name }}" ]; then |
239 | 248 | 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 |
242 | 251 | fi |
| 252 | +
|
243 | 253 | |
244 | 254 | sync-framagit: |
245 | 255 | runs-on: ubuntu-latest |
@@ -272,17 +282,17 @@ jobs: |
272 | 282 |
|
273 | 283 | # 添加远端 |
274 | 284 | - 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" |
276 | 286 |
|
277 | 287 | # 获取 |
278 | 288 | - name: fetch |
279 | | - run: git fetch --prune framagit --tags --verbose |
| 289 | + run: git fetch --prune mirror --tags --verbose |
280 | 290 |
|
281 | | - # 拉取 |
| 291 | + # 拉取和推送 |
282 | 292 | - name: pull and push |
283 | 293 | run: | |
284 | 294 | if [ "${{ github.ref_name }}" ]; then |
285 | 295 | 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 |
288 | 298 | fi |
0 commit comments