|
| 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-gitlink: |
| 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 "[email protected]" |
| 24 | + git config --global user.name "AlianBlank" |
| 25 | +
|
| 26 | + - name: Set SSH |
| 27 | + run: | |
| 28 | + mkdir -p ~/.ssh |
| 29 | + echo "${{ secrets.GITLINK_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 code.gitlink.org.cn >> ~/.ssh/known_hosts |
| 34 | +
|
| 35 | + # 查看当前分支 |
| 36 | + - name: Check current branch |
| 37 | + run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
| 38 | + |
| 39 | + # 查看远端 地址 |
| 40 | + - name: echo git url |
| 41 | + run: echo [email protected]:${{ github.Repository }}.git |
| 42 | + |
| 43 | + # 添加远端 |
| 44 | + - name: add remote url |
| 45 | + run: git remote add gitlink "[email protected]:${{ github.Repository }}.git" |
| 46 | + |
| 47 | + # 获取 |
| 48 | + - name: fetch |
| 49 | + run: git fetch --prune gitlink --tags --verbose |
| 50 | + |
| 51 | + # 拉取 |
| 52 | + - name: pull and push |
| 53 | + run: | |
| 54 | + if [ "${{ github.ref_name }}" ]; then |
| 55 | + 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 |
| 58 | + fi |
| 59 | +
|
| 60 | + sync-gitlab: |
| 61 | + runs-on: ubuntu-latest |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Checkout code |
| 65 | + uses: actions/checkout@v4 |
| 66 | + with: |
| 67 | + fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史 |
| 68 | + |
| 69 | + - name: Set up Git user |
| 70 | + run: | |
| 71 | + git config --global user.email "[email protected]" |
| 72 | + git config --global user.name "AlianBlank" |
| 73 | +
|
| 74 | + - name: Set SSH |
| 75 | + run: | |
| 76 | + mkdir -p ~/.ssh |
| 77 | + echo "${{ secrets.GITLAB_ID_RSA }}" >> ~/.ssh/id_rsa |
| 78 | + chmod 600 ~/.ssh/id_rsa |
| 79 | + eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa |
| 80 | + # 信任域名 |
| 81 | + ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts |
| 82 | + # 查看当前分支 |
| 83 | + - name: Check current branch |
| 84 | + run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
| 85 | + # 查看远端 地址 |
| 86 | + - name: echo git url |
| 87 | + run: echo [email protected]:${{ github.Repository }}.git |
| 88 | + |
| 89 | + # 添加远端 |
| 90 | + - name: add remote url |
| 91 | + run: git remote add gitlab "[email protected]:${{ github.Repository }}.git" |
| 92 | + |
| 93 | + # 获取 |
| 94 | + - name: fetch |
| 95 | + run: git fetch --prune gitlab --tags --verbose |
| 96 | + |
| 97 | + # 拉取 |
| 98 | + - name: pull and push |
| 99 | + run: | |
| 100 | + if [ "${{ github.ref_name }}" ]; then |
| 101 | + 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 |
| 104 | + fi |
| 105 | +
|
| 106 | + sync-gitee: |
| 107 | + runs-on: ubuntu-latest |
| 108 | + |
| 109 | + steps: |
| 110 | + - name: Checkout code |
| 111 | + uses: actions/checkout@v4 |
| 112 | + with: |
| 113 | + fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史 |
| 114 | + |
| 115 | + - name: Set up Git user |
| 116 | + run: | |
| 117 | + git config --global user.email "[email protected]" |
| 118 | + git config --global user.name "AlianBlank" |
| 119 | +
|
| 120 | + - name: Set SSH |
| 121 | + run: | |
| 122 | + mkdir -p ~/.ssh |
| 123 | + echo "${{ secrets.GITEE_ID_RSA }}" >> ~/.ssh/id_rsa |
| 124 | + chmod 600 ~/.ssh/id_rsa |
| 125 | + eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa |
| 126 | + # 信任域名 |
| 127 | + ssh-keyscan -H gitee.com >> ~/.ssh/known_hosts |
| 128 | + # 查看当前分支 |
| 129 | + - name: Check current branch |
| 130 | + run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
| 131 | + # 查看远端 地址 |
| 132 | + - name: echo git url |
| 133 | + run: echo [email protected]:${{ github.Repository }}.git |
| 134 | + |
| 135 | + # 添加远端 |
| 136 | + - name: add remote url |
| 137 | + run: git remote add gitee "[email protected]:${{ github.Repository }}.git" |
| 138 | + |
| 139 | + # 获取 |
| 140 | + - name: fetch |
| 141 | + run: git fetch --prune gitee --tags --verbose |
| 142 | + |
| 143 | + # 拉取 |
| 144 | + - name: pull and push |
| 145 | + run: | |
| 146 | + if [ "${{ github.ref_name }}" ]; then |
| 147 | + 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 |
| 150 | + fi |
| 151 | +
|
| 152 | + sync-atomgit: |
| 153 | + runs-on: ubuntu-latest |
| 154 | + |
| 155 | + steps: |
| 156 | + - name: Checkout code |
| 157 | + uses: actions/checkout@v4 |
| 158 | + with: |
| 159 | + fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史 |
| 160 | + |
| 161 | + - name: Set up Git user |
| 162 | + run: | |
| 163 | + git config --global user.email "[email protected]" |
| 164 | + git config --global user.name "AlianBlank" |
| 165 | +
|
| 166 | + - name: Set SSH |
| 167 | + run: | |
| 168 | + mkdir -p ~/.ssh |
| 169 | + echo "${{ secrets.ATOMGIT_ID_RSA }}" >> ~/.ssh/id_rsa |
| 170 | + chmod 600 ~/.ssh/id_rsa |
| 171 | + eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa |
| 172 | + # 信任域名 |
| 173 | + ssh-keyscan -H atomgit.com >> ~/.ssh/known_hosts |
| 174 | + # 查看当前分支 |
| 175 | + - name: Check current branch |
| 176 | + run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
| 177 | + # 查看远端 地址 |
| 178 | + - name: echo git url |
| 179 | + run: echo [email protected]:${{ github.Repository }}.git |
| 180 | + |
| 181 | + # 添加远端 |
| 182 | + - name: add remote url |
| 183 | + run: git remote add atomgit "[email protected]:${{ github.Repository }}.git" |
| 184 | + |
| 185 | + # 获取 |
| 186 | + - name: fetch |
| 187 | + run: git fetch --prune atomgit --tags --verbose |
| 188 | + |
| 189 | + # 拉取 |
| 190 | + - name: pull and push |
| 191 | + run: | |
| 192 | + if [ "${{ github.ref_name }}" ]; then |
| 193 | + 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 |
| 196 | + fi |
| 197 | +
|
| 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 "[email protected]" |
| 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 [email protected]:${{ github.Repository }}.git |
| 226 | + |
| 227 | + # 添加远端 |
| 228 | + - name: add remote url |
| 229 | + run: git remote add gitcode "[email protected]:${{ github.Repository }}.git" |
| 230 | + |
| 231 | + # 获取 |
| 232 | + - name: fetch |
| 233 | + run: git fetch --prune gitcode --tags --verbose |
| 234 | + |
| 235 | + # 拉取 |
| 236 | + - name: pull and push |
| 237 | + run: | |
| 238 | + 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 |
| 242 | + fi |
| 243 | + |
| 244 | + sync-framagit: |
| 245 | + runs-on: ubuntu-latest |
| 246 | + |
| 247 | + steps: |
| 248 | + - name: Checkout code |
| 249 | + uses: actions/checkout@v4 |
| 250 | + with: |
| 251 | + fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史 |
| 252 | + |
| 253 | + - name: Set up Git user |
| 254 | + run: | |
| 255 | + git config --global user.email "[email protected]" |
| 256 | + git config --global user.name "AlianBlank" |
| 257 | +
|
| 258 | + - name: Set SSH |
| 259 | + run: | |
| 260 | + mkdir -p ~/.ssh |
| 261 | + echo "${{ secrets.FRAMAGIT_ID_RSA }}" >> ~/.ssh/id_rsa |
| 262 | + chmod 600 ~/.ssh/id_rsa |
| 263 | + eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa |
| 264 | + # 信任域名 |
| 265 | + ssh-keyscan -H framagit.org >> ~/.ssh/known_hosts |
| 266 | + # 查看当前分支 |
| 267 | + - name: Check current branch |
| 268 | + run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }} |
| 269 | + # 查看远端 地址 |
| 270 | + - name: echo git url |
| 271 | + run: echo [email protected]:${{ github.Repository }}.git |
| 272 | + |
| 273 | + # 添加远端 |
| 274 | + - name: add remote url |
| 275 | + run: git remote add framagit "[email protected]:${{ github.Repository }}.git" |
| 276 | + |
| 277 | + # 获取 |
| 278 | + - name: fetch |
| 279 | + run: git fetch --prune framagit --tags --verbose |
| 280 | + |
| 281 | + # 拉取 |
| 282 | + - name: pull and push |
| 283 | + run: | |
| 284 | + if [ "${{ github.ref_name }}" ]; then |
| 285 | + 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 |
| 288 | + fi |
0 commit comments