|
1 | 1 | # SPDX-License-Identifier: AGPL-3.0-or-later |
2 | | -name: Mirror to GitLab/Codeberg/Bitbucket |
| 2 | +# SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell |
| 3 | +name: Mirror to Git Forges |
3 | 4 |
|
4 | 5 | on: |
5 | 6 | push: |
6 | | - branches: [main, master] |
| 7 | + branches: [main] |
7 | 8 | workflow_dispatch: |
8 | 9 |
|
9 | 10 | permissions: read-all |
10 | 11 |
|
11 | | -# Prevent concurrent mirror operations to avoid race conditions |
12 | | -concurrency: |
13 | | - group: mirror-${{ github.ref }} |
14 | | - cancel-in-progress: false |
15 | | - |
16 | | -env: |
17 | | - # SSH known hosts for mirror targets (prevents MITM attacks) |
18 | | - GITLAB_HOST_KEY: "gitlab.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf" |
19 | | - CODEBERG_HOST_KEY: "codeberg.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIVIC02vnjFyL+I4RHfvIGNtOgJMe769VTF1VR4EB3ZB" |
20 | | - BITBUCKET_HOST_KEY: "bitbucket.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIazEu89wgQZ4bqs3d63QSMzYVa0MuJ2e2gKTKqu+UUO" |
21 | | - |
22 | 12 | jobs: |
23 | 13 | mirror-gitlab: |
24 | 14 | runs-on: ubuntu-latest |
25 | | - timeout-minutes: 10 |
26 | 15 | if: vars.GITLAB_MIRROR_ENABLED == 'true' |
27 | 16 | steps: |
28 | | - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 |
| 17 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
29 | 18 | with: |
30 | 19 | fetch-depth: 0 |
31 | | - persist-credentials: false |
32 | | - - name: Configure SSH known hosts |
33 | | - run: | |
34 | | - mkdir -p ~/.ssh |
35 | | - echo "${{ env.GITLAB_HOST_KEY }}" >> ~/.ssh/known_hosts |
36 | | - chmod 600 ~/.ssh/known_hosts |
37 | | - - uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1 |
| 20 | + |
| 21 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
38 | 22 | with: |
39 | 23 | ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} |
| 24 | + |
40 | 25 | - name: Mirror to GitLab |
41 | | - shell: bash |
42 | 26 | run: | |
43 | | - set -euo pipefail |
44 | | - git remote add gitlab "git@gitlab.com:hyperpolymath/${GITHUB_REPOSITORY#*/}.git" 2>/dev/null || git remote set-url gitlab "git@gitlab.com:hyperpolymath/${GITHUB_REPOSITORY#*/}.git" |
45 | | - git push gitlab --all --force |
46 | | - git push gitlab --tags --force |
| 27 | + ssh-keyscan -t ed25519 gitlab.com >> ~/.ssh/known_hosts |
| 28 | + git remote add gitlab git@gitlab.com:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 29 | + git push --force gitlab main |
| 30 | +
|
| 31 | + mirror-bitbucket: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + if: vars.BITBUCKET_MIRROR_ENABLED == 'true' |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
| 40 | + with: |
| 41 | + ssh-private-key: ${{ secrets.BITBUCKET_SSH_KEY }} |
| 42 | + |
| 43 | + - name: Mirror to Bitbucket |
| 44 | + run: | |
| 45 | + ssh-keyscan -t ed25519 bitbucket.org >> ~/.ssh/known_hosts |
| 46 | + git remote add bitbucket git@bitbucket.org:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 47 | + git push --force bitbucket main |
47 | 48 |
|
48 | 49 | mirror-codeberg: |
49 | 50 | runs-on: ubuntu-latest |
50 | | - timeout-minutes: 10 |
51 | 51 | if: vars.CODEBERG_MIRROR_ENABLED == 'true' |
52 | 52 | steps: |
53 | | - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 |
| 53 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
54 | 54 | with: |
55 | 55 | fetch-depth: 0 |
56 | | - persist-credentials: false |
57 | | - - name: Configure SSH known hosts |
58 | | - run: | |
59 | | - mkdir -p ~/.ssh |
60 | | - echo "${{ env.CODEBERG_HOST_KEY }}" >> ~/.ssh/known_hosts |
61 | | - chmod 600 ~/.ssh/known_hosts |
62 | | - - uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1 |
| 56 | + |
| 57 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
63 | 58 | with: |
64 | 59 | ssh-private-key: ${{ secrets.CODEBERG_SSH_KEY }} |
| 60 | + |
65 | 61 | - name: Mirror to Codeberg |
66 | | - shell: bash |
67 | 62 | run: | |
68 | | - set -euo pipefail |
69 | | - git remote add codeberg "git@codeberg.org:hyperpolymath/${GITHUB_REPOSITORY#*/}.git" 2>/dev/null || git remote set-url codeberg "git@codeberg.org:hyperpolymath/${GITHUB_REPOSITORY#*/}.git" |
70 | | - git push codeberg --all --force |
71 | | - git push codeberg --tags --force |
| 63 | + ssh-keyscan -t ed25519 codeberg.org >> ~/.ssh/known_hosts |
| 64 | + git remote add codeberg git@codeberg.org:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 65 | + git push --force codeberg main |
72 | 66 |
|
73 | | - mirror-bitbucket: |
| 67 | + mirror-sourcehut: |
74 | 68 | runs-on: ubuntu-latest |
75 | | - timeout-minutes: 10 |
76 | | - if: vars.BITBUCKET_MIRROR_ENABLED == 'true' |
| 69 | + if: vars.SOURCEHUT_MIRROR_ENABLED == 'true' |
77 | 70 | steps: |
78 | | - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 |
| 71 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
79 | 72 | with: |
80 | 73 | fetch-depth: 0 |
81 | | - persist-credentials: false |
82 | | - - name: Configure SSH known hosts |
| 74 | + |
| 75 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
| 76 | + with: |
| 77 | + ssh-private-key: ${{ secrets.SOURCEHUT_SSH_KEY }} |
| 78 | + |
| 79 | + - name: Mirror to SourceHut |
83 | 80 | run: | |
84 | | - mkdir -p ~/.ssh |
85 | | - echo "${{ env.BITBUCKET_HOST_KEY }}" >> ~/.ssh/known_hosts |
86 | | - chmod 600 ~/.ssh/known_hosts |
87 | | - - uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1 |
| 81 | + ssh-keyscan -t ed25519 git.sr.ht >> ~/.ssh/known_hosts |
| 82 | + git remote add sourcehut git@git.sr.ht:~hyperpolymath/${{ github.event.repository.name }} || true |
| 83 | + git push --force sourcehut main |
| 84 | +
|
| 85 | + mirror-disroot: |
| 86 | + runs-on: ubuntu-latest |
| 87 | + if: vars.DISROOT_MIRROR_ENABLED == 'true' |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
88 | 90 | with: |
89 | | - ssh-private-key: ${{ secrets.BITBUCKET_SSH_KEY }} |
90 | | - - name: Mirror to Bitbucket |
91 | | - shell: bash |
| 91 | + fetch-depth: 0 |
| 92 | + |
| 93 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
| 94 | + with: |
| 95 | + ssh-private-key: ${{ secrets.DISROOT_SSH_KEY }} |
| 96 | + |
| 97 | + - name: Mirror to Disroot |
| 98 | + run: | |
| 99 | + ssh-keyscan -t ed25519 git.disroot.org >> ~/.ssh/known_hosts |
| 100 | + git remote add disroot git@git.disroot.org:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 101 | + git push --force disroot main |
| 102 | +
|
| 103 | + mirror-gitea: |
| 104 | + runs-on: ubuntu-latest |
| 105 | + if: vars.GITEA_MIRROR_ENABLED == 'true' |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 108 | + with: |
| 109 | + fetch-depth: 0 |
| 110 | + |
| 111 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
| 112 | + with: |
| 113 | + ssh-private-key: ${{ secrets.GITEA_SSH_KEY }} |
| 114 | + |
| 115 | + - name: Mirror to Gitea |
| 116 | + run: | |
| 117 | + ssh-keyscan -t ed25519 ${{ vars.GITEA_HOST }} >> ~/.ssh/known_hosts |
| 118 | + git remote add gitea git@${{ vars.GITEA_HOST }}:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 119 | + git push --force gitea main |
| 120 | +
|
| 121 | + mirror-radicle: |
| 122 | + runs-on: ubuntu-latest |
| 123 | + if: vars.RADICLE_MIRROR_ENABLED == 'true' |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 126 | + with: |
| 127 | + fetch-depth: 0 |
| 128 | + |
| 129 | + - name: Install Radicle |
| 130 | + run: | |
| 131 | + curl -sSf https://radicle.xyz/install | sh |
| 132 | + echo "$HOME/.radicle/bin" >> $GITHUB_PATH |
| 133 | +
|
| 134 | + - name: Mirror to Radicle |
92 | 135 | run: | |
93 | | - set -euo pipefail |
94 | | - git remote add bitbucket "git@bitbucket.org:hyperpolymath/${GITHUB_REPOSITORY#*/}.git" 2>/dev/null || git remote set-url bitbucket "git@bitbucket.org:hyperpolymath/${GITHUB_REPOSITORY#*/}.git" |
95 | | - git push bitbucket --all --force |
96 | | - git push bitbucket --tags --force |
| 136 | + echo "${{ secrets.RADICLE_KEY }}" > ~/.radicle/keys/radicle |
| 137 | + chmod 600 ~/.radicle/keys/radicle |
| 138 | + rad sync --announce || echo "Radicle sync attempted" |
0 commit comments