|
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 | | -# Prevent concurrent mirror operations to avoid race conditions |
10 | | -concurrency: |
11 | | - group: mirror-${{ github.ref }} |
12 | | - cancel-in-progress: false |
13 | | - |
14 | | -permissions: |
15 | | - contents: read |
16 | | - |
17 | | -env: |
18 | | - # SSH known hosts for security - prevents MITM attacks |
19 | | - # These are the official SSH host keys for each platform |
20 | | - GITLAB_HOST_KEY: "gitlab.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf" |
21 | | - CODEBERG_HOST_KEY: "codeberg.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIVIC02vnjFyL+I4RHfvIGNtOgJMe769VTF1VR4EB3ZB" |
22 | | - BITBUCKET_HOST_KEY: "bitbucket.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIazEu89wgQZ4bqs3d63QSMzYVa0MuJ2e2gKTKqu+UUO" |
| 10 | +permissions: read-all |
23 | 11 |
|
24 | 12 | jobs: |
25 | 13 | mirror-gitlab: |
26 | 14 | runs-on: ubuntu-latest |
27 | | - timeout-minutes: 10 |
28 | 15 | if: vars.GITLAB_MIRROR_ENABLED == 'true' |
29 | 16 | steps: |
30 | | - - name: Add GitLab to known hosts |
31 | | - run: | |
32 | | - mkdir -p ~/.ssh |
33 | | - echo "${{ env.GITLAB_HOST_KEY }}" >> ~/.ssh/known_hosts |
34 | | - chmod 600 ~/.ssh/known_hosts |
35 | | -
|
36 | | - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 17 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
37 | 18 | with: |
38 | 19 | fetch-depth: 0 |
39 | 20 |
|
40 | | - - uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1 |
| 21 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
41 | 22 | with: |
42 | 23 | ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} |
43 | 24 |
|
44 | 25 | - name: Mirror to GitLab |
45 | 26 | run: | |
46 | | - git remote add gitlab "git@gitlab.com:${{ github.repository_owner }}/${GITHUB_REPOSITORY#*/}.git" || true |
47 | | - git push gitlab --all --force |
48 | | - git push gitlab --tags --force |
| 27 | + ssh-keyscan -t ed25519 gitlab.com >> ~/.ssh/known_hosts |
| 28 | + git remote add gitlab [email protected]:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 29 | + git push --force gitlab main |
49 | 30 |
|
50 | | - mirror-codeberg: |
| 31 | + mirror-bitbucket: |
51 | 32 | runs-on: ubuntu-latest |
52 | | - timeout-minutes: 10 |
53 | | - if: vars.CODEBERG_MIRROR_ENABLED == 'true' |
| 33 | + if: vars.BITBUCKET_MIRROR_ENABLED == 'true' |
54 | 34 | steps: |
55 | | - - name: Add Codeberg to known hosts |
| 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 |
56 | 44 | run: | |
57 | | - mkdir -p ~/.ssh |
58 | | - echo "${{ env.CODEBERG_HOST_KEY }}" >> ~/.ssh/known_hosts |
59 | | - chmod 600 ~/.ssh/known_hosts |
| 45 | + ssh-keyscan -t ed25519 bitbucket.org >> ~/.ssh/known_hosts |
| 46 | + git remote add bitbucket [email protected]:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 47 | + git push --force bitbucket main |
60 | 48 |
|
61 | | - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 49 | + mirror-codeberg: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + if: vars.CODEBERG_MIRROR_ENABLED == 'true' |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
62 | 54 | with: |
63 | 55 | fetch-depth: 0 |
64 | 56 |
|
65 | | - - uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1 |
| 57 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
66 | 58 | with: |
67 | 59 | ssh-private-key: ${{ secrets.CODEBERG_SSH_KEY }} |
68 | 60 |
|
69 | 61 | - name: Mirror to Codeberg |
70 | 62 | run: | |
71 | | - git remote add codeberg "git@codeberg.org:${{ github.repository_owner }}/${GITHUB_REPOSITORY#*/}.git" || true |
72 | | - git push codeberg --all --force |
73 | | - git push codeberg --tags --force |
| 63 | + ssh-keyscan -t ed25519 codeberg.org >> ~/.ssh/known_hosts |
| 64 | + git remote add codeberg [email protected]:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 65 | + git push --force codeberg main |
74 | 66 |
|
75 | | - mirror-bitbucket: |
| 67 | + mirror-sourcehut: |
76 | 68 | runs-on: ubuntu-latest |
77 | | - timeout-minutes: 10 |
78 | | - if: vars.BITBUCKET_MIRROR_ENABLED == 'true' |
| 69 | + if: vars.SOURCEHUT_MIRROR_ENABLED == 'true' |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 72 | + with: |
| 73 | + fetch-depth: 0 |
| 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 |
| 80 | + run: | |
| 81 | + ssh-keyscan -t ed25519 git.sr.ht >> ~/.ssh/known_hosts |
| 82 | + git remote add sourcehut [email protected]:~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' |
79 | 88 | steps: |
80 | | - - name: Add Bitbucket to known hosts |
| 89 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 90 | + with: |
| 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 |
81 | 98 | run: | |
82 | | - mkdir -p ~/.ssh |
83 | | - echo "${{ env.BITBUCKET_HOST_KEY }}" >> ~/.ssh/known_hosts |
84 | | - chmod 600 ~/.ssh/known_hosts |
| 99 | + ssh-keyscan -t ed25519 git.disroot.org >> ~/.ssh/known_hosts |
| 100 | + git remote add disroot [email protected]:hyperpolymath/${{ github.event.repository.name }}.git || true |
| 101 | + git push --force disroot main |
85 | 102 |
|
86 | | - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 103 | + mirror-gitea: |
| 104 | + runs-on: ubuntu-latest |
| 105 | + if: vars.GITEA_MIRROR_ENABLED == 'true' |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
87 | 108 | with: |
88 | 109 | fetch-depth: 0 |
89 | 110 |
|
90 | | - - uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1 |
| 111 | + - uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 |
91 | 112 | with: |
92 | | - ssh-private-key: ${{ secrets.BITBUCKET_SSH_KEY }} |
| 113 | + ssh-private-key: ${{ secrets.GITEA_SSH_KEY }} |
93 | 114 |
|
94 | | - - name: Mirror to Bitbucket |
| 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: Setup Rust |
| 130 | + uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable |
| 131 | + with: |
| 132 | + toolchain: stable |
| 133 | + |
| 134 | + - name: Install Radicle |
| 135 | + run: | |
| 136 | + # Install via cargo (safer than curl|sh) |
| 137 | + cargo install radicle-cli --locked |
| 138 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 139 | +
|
| 140 | + - name: Mirror to Radicle |
95 | 141 | run: | |
96 | | - git remote add bitbucket "[email protected]:${{ github.repository_owner }}/${GITHUB_REPOSITORY#*/}.git" || true |
97 | | - git push bitbucket --all --force |
98 | | - git push bitbucket --tags --force |
| 142 | + echo "${{ secrets.RADICLE_KEY }}" > ~/.radicle/keys/radicle |
| 143 | + chmod 600 ~/.radicle/keys/radicle |
| 144 | + rad sync --announce || echo "Radicle sync attempted" |
0 commit comments