|
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 | | - schedule: |
7 | | - # 定时任务,每天 UTC 时间 20 点 50运行 |
8 | | - - cron: "50 20 * * *" |
| 10 | + #schedule: |
| 11 | + # 定时任务,每天 UTC 时间 0 点运行 |
| 12 | + #- cron: "0 0 * * *" |
9 | 13 | workflow_dispatch: |
10 | 14 |
|
| 15 | + |
11 | 16 | jobs: |
12 | 17 | sync-gitlink: |
13 | 18 | runs-on: ubuntu-latest |
@@ -42,27 +47,69 @@ jobs: |
42 | 47 |
|
43 | 48 | # 添加远端 |
44 | 49 | - name: add remote url |
45 | | - run: git remote add gitlink "git@code.gitlink.org.cn:${{ github.Repository }}.git" |
| 50 | + run: git remote add mirror "git@code.gitlink.org.cn:${{ 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 | | - # 拉取 |
52 | | - - name: pull |
| 56 | + # 拉取和推送 |
| 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 }}分支; |
| 61 | + git push -f mirror ${{ github.ref_name }} |
| 62 | + git push -f mirror --tags --verbose |
57 | 63 | fi |
58 | 64 |
|
59 | | - # 推送 |
60 | | - - name: push |
| 65 | +
|
| 66 | + sync-gitlab: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Checkout code |
| 71 | + uses: actions/checkout@v4 |
| 72 | + with: |
| 73 | + fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史 |
| 74 | + |
| 75 | + - name: Set up Git user |
| 76 | + run: | |
| 77 | + git config --global user.email "wangfj11@foxmail.com" |
| 78 | + git config --global user.name "AlianBlank" |
| 79 | +
|
| 80 | + - name: Set SSH |
| 81 | + run: | |
| 82 | + mkdir -p ~/.ssh |
| 83 | + echo "${{ secrets.GITLAB_ID_RSA }}" >> ~/.ssh/id_rsa |
| 84 | + chmod 600 ~/.ssh/id_rsa |
| 85 | + eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa |
| 86 | + # 信任域名 |
| 87 | + ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts |
| 88 | + # 查看当前分支 |
| 89 | + - name: Check current branch |
| 90 | + run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
| 91 | + # 查看远端 地址 |
| 92 | + - name: echo git url |
| 93 | + run: echo git@gitlab.com:${{ github.Repository }}.git |
| 94 | + |
| 95 | + # 添加远端 |
| 96 | + - name: add remote url |
| 97 | + run: git remote add mirror "git@gitlab.com:${{ github.Repository }}.git" |
| 98 | + |
| 99 | + # 获取 |
| 100 | + - name: fetch |
| 101 | + run: git fetch --prune mirror --tags --verbose |
| 102 | + |
| 103 | + # 拉取和推送 |
| 104 | + - name: pull and push |
61 | 105 | run: | |
62 | 106 | if [ "${{ github.ref_name }}" ]; then |
63 | | - git push -u --force gitlink ${{ github.ref_name }} --tags --verbose |
| 107 | + git checkout ${{ github.ref_name }} |
| 108 | + git push -f mirror ${{ github.ref_name }} |
| 109 | + git push -f mirror --tags --verbose |
64 | 110 | fi |
65 | 111 |
|
| 112 | +
|
66 | 113 | sync-gitee: |
67 | 114 | runs-on: ubuntu-latest |
68 | 115 |
|
@@ -94,26 +141,21 @@ jobs: |
94 | 141 |
|
95 | 142 | # 添加远端 |
96 | 143 | - name: add remote url |
97 | | - run: git remote add gitee "git@gitee.com:${{ github.Repository }}.git" |
| 144 | + run: git remote add mirror "git@gitee.com:${{ github.Repository }}.git" |
98 | 145 |
|
99 | 146 | # 获取 |
100 | 147 | - name: fetch |
101 | | - run: git fetch --prune gitee --tags --verbose |
| 148 | + run: git fetch --prune mirror --tags --verbose |
102 | 149 |
|
103 | | - # 拉取 |
104 | | - - name: pull |
| 150 | + # 拉取和推送 |
| 151 | + - name: pull and push |
105 | 152 | run: | |
106 | 153 | if [ "${{ github.ref_name }}" ]; then |
107 | 154 | git checkout ${{ github.ref_name }} |
108 | | - git pull --progress -v --no-rebase gitee ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支; |
| 155 | + git push -f mirror ${{ github.ref_name }} |
| 156 | + git push -f mirror --tags --verbose |
109 | 157 | fi |
110 | 158 |
|
111 | | - # 推送 |
112 | | - - name: push |
113 | | - run: | |
114 | | - if [ "${{ github.ref_name }}" ]; then |
115 | | - git push -u --force gitee ${{ github.ref_name }} --tags --verbose |
116 | | - fi |
117 | 159 |
|
118 | 160 | sync-atomgit: |
119 | 161 | runs-on: ubuntu-latest |
@@ -146,76 +188,111 @@ jobs: |
146 | 188 |
|
147 | 189 | # 添加远端 |
148 | 190 | - name: add remote url |
149 | | - run: git remote add atomgit "git@atomgit.com:${{ github.Repository }}.git" |
| 191 | + run: git remote add mirror "git@atomgit.com:${{ github.Repository }}.git" |
150 | 192 |
|
151 | 193 | # 获取 |
152 | 194 | - name: fetch |
153 | | - run: git fetch --prune atomgit --tags --verbose |
| 195 | + run: git fetch --prune mirror --tags --verbose |
154 | 196 |
|
155 | | - # 拉取 |
156 | | - - name: pull |
| 197 | + # 拉取和推送 |
| 198 | + - name: pull and push |
157 | 199 | run: | |
158 | 200 | if [ "${{ github.ref_name }}" ]; then |
159 | 201 | git checkout ${{ github.ref_name }} |
160 | | - git pull --progress -v --no-rebase atomgit ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支; |
| 202 | + git push -f mirror ${{ github.ref_name }} |
| 203 | + git push -f mirror --tags --verbose |
161 | 204 | fi |
162 | 205 |
|
163 | | - # 推送 |
164 | | - - name: push |
| 206 | +
|
| 207 | + sync-gitcode: |
| 208 | + runs-on: ubuntu-latest |
| 209 | + |
| 210 | + steps: |
| 211 | + - name: Checkout code |
| 212 | + uses: actions/checkout@v4 |
| 213 | + with: |
| 214 | + fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史 |
| 215 | + |
| 216 | + - name: Set up Git user |
| 217 | + run: | |
| 218 | + git config --global user.email "wangfj11@foxmail.com" |
| 219 | + git config --global user.name "AlianBlank" |
| 220 | +
|
| 221 | + - name: Set SSH |
| 222 | + run: | |
| 223 | + mkdir -p ~/.ssh |
| 224 | + echo "${{ secrets.GITCODE_ID_RSA }}" >> ~/.ssh/id_rsa |
| 225 | + chmod 600 ~/.ssh/id_rsa |
| 226 | + eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa |
| 227 | + # 信任域名 |
| 228 | + ssh-keyscan -H gitcode.net >> ~/.ssh/known_hosts |
| 229 | + # 查看当前分支 |
| 230 | + - name: Check current branch |
| 231 | + run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
| 232 | + # 查看远端 地址 |
| 233 | + - name: echo git url |
| 234 | + run: echo git@gitcode.net:${{ github.Repository }}.git |
| 235 | + |
| 236 | + # 添加远端 |
| 237 | + - name: add remote url |
| 238 | + run: git remote add mirror "git@gitcode.net:${{ github.Repository }}.git" |
| 239 | + |
| 240 | + # 获取 |
| 241 | + - name: fetch |
| 242 | + run: git fetch --prune mirror --tags --verbose |
| 243 | + |
| 244 | + # 拉取和推送 |
| 245 | + - name: pull and push |
165 | 246 | run: | |
166 | 247 | if [ "${{ github.ref_name }}" ]; then |
167 | | - git push -u --force atomgit ${{ github.ref_name }} --tags --verbose |
| 248 | + git checkout ${{ github.ref_name }} |
| 249 | + git push -f mirror ${{ github.ref_name }} |
| 250 | + git push -f mirror --tags --verbose |
168 | 251 | fi |
169 | 252 |
|
170 | | - # sync-gitcode: |
171 | | - # runs-on: ubuntu-latest |
172 | | - |
173 | | - # steps: |
174 | | - # - name: Checkout code |
175 | | - # uses: actions/checkout@v4 |
176 | | - # with: |
177 | | - # fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史 |
178 | | - |
179 | | - # - name: Set up Git user |
180 | | - # run: | |
181 | | - # git config --global user.email "wangfj11@foxmail.com" |
182 | | - # git config --global user.name "AlianBlank" |
183 | | - |
184 | | - # - name: Set SSH |
185 | | - # run: | |
186 | | - # mkdir -p ~/.ssh |
187 | | - # echo "${{ secrets.GITCODE_ID_RSA }}" >> ~/.ssh/id_rsa |
188 | | - # chmod 600 ~/.ssh/id_rsa |
189 | | - # eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa |
190 | | - # # 信任域名 |
191 | | - # ssh-keyscan -H gitcode.net >> ~/.ssh/known_hosts |
192 | | - # # 查看当前分支 |
193 | | - # - name: Check current branch |
194 | | - # run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
195 | | - # # 查看远端 地址 |
196 | | - # - name: echo git url |
197 | | - # run: echo git@gitcode.net:${{ github.Repository }}.git |
198 | | - |
199 | | - # # 添加远端 |
200 | | - # - name: add remote url |
201 | | - # run: git remote add gitcode "git@gitcode.net:${{ github.Repository }}.git" |
202 | | - |
203 | | - # # 获取 |
204 | | - # - name: fetch |
205 | | - # run: git fetch --prune gitcode --tags --verbose |
206 | | - |
207 | | - # # 拉取 |
208 | | - # - name: pull |
209 | | - # run: | |
210 | | - # if [ "${{ github.ref_name }}" ]; then |
211 | | - # git checkout ${{ github.ref_name }} |
212 | | - # git pull --progress -v --no-rebase gitcode ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支; |
213 | | - # fi |
214 | | - |
215 | | - # # 推送 |
216 | | - # - name: push |
217 | | - # run: | |
218 | | - # if [ "${{ github.ref_name }}" ]; then |
219 | | - # git push -u --force gitcode ${{ github.ref_name }} --tags --verbose |
220 | | - # fi |
221 | 253 | |
| 254 | + sync-framagit: |
| 255 | + runs-on: ubuntu-latest |
| 256 | + |
| 257 | + steps: |
| 258 | + - name: Checkout code |
| 259 | + uses: actions/checkout@v4 |
| 260 | + with: |
| 261 | + fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史 |
| 262 | + |
| 263 | + - name: Set up Git user |
| 264 | + run: | |
| 265 | + git config --global user.email "wangfj11@foxmail.com" |
| 266 | + git config --global user.name "AlianBlank" |
| 267 | +
|
| 268 | + - name: Set SSH |
| 269 | + run: | |
| 270 | + mkdir -p ~/.ssh |
| 271 | + echo "${{ secrets.FRAMAGIT_ID_RSA }}" >> ~/.ssh/id_rsa |
| 272 | + chmod 600 ~/.ssh/id_rsa |
| 273 | + eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa |
| 274 | + # 信任域名 |
| 275 | + ssh-keyscan -H framagit.org >> ~/.ssh/known_hosts |
| 276 | + # 查看当前分支 |
| 277 | + - name: Check current branch |
| 278 | + run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
| 279 | + # 查看远端 地址 |
| 280 | + - name: echo git url |
| 281 | + run: echo git@framagit.org:${{ github.Repository }}.git |
| 282 | + |
| 283 | + # 添加远端 |
| 284 | + - name: add remote url |
| 285 | + run: git remote add mirror "git@framagit.org:${{ github.Repository }}.git" |
| 286 | + |
| 287 | + # 获取 |
| 288 | + - name: fetch |
| 289 | + run: git fetch --prune mirror --tags --verbose |
| 290 | + |
| 291 | + # 拉取和推送 |
| 292 | + - name: pull and push |
| 293 | + run: | |
| 294 | + if [ "${{ github.ref_name }}" ]; then |
| 295 | + git checkout ${{ github.ref_name }} |
| 296 | + git push -f mirror ${{ github.ref_name }} |
| 297 | + git push -f mirror --tags --verbose |
| 298 | + fi |
0 commit comments