Skip to content

Commit c1c0a35

Browse files
committed
chore: update mirror workflow for multi-forge sync
1 parent 1d41123 commit c1c0a35

1 file changed

Lines changed: 100 additions & 58 deletions

File tree

.github/workflows/mirror.yml

Lines changed: 100 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,138 @@
11
# 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
34

45
on:
56
push:
6-
branches: [main, master]
7+
branches: [main]
78
workflow_dispatch:
89

910
permissions: read-all
1011

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-
2212
jobs:
2313
mirror-gitlab:
2414
runs-on: ubuntu-latest
25-
timeout-minutes: 10
2615
if: vars.GITLAB_MIRROR_ENABLED == 'true'
2716
steps:
28-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
17+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
2918
with:
3019
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
3822
with:
3923
ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }}
24+
4025
- name: Mirror to GitLab
41-
shell: bash
4226
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
4748
4849
mirror-codeberg:
4950
runs-on: ubuntu-latest
50-
timeout-minutes: 10
5151
if: vars.CODEBERG_MIRROR_ENABLED == 'true'
5252
steps:
53-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
53+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
5454
with:
5555
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
6358
with:
6459
ssh-private-key: ${{ secrets.CODEBERG_SSH_KEY }}
60+
6561
- name: Mirror to Codeberg
66-
shell: bash
6762
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
7266
73-
mirror-bitbucket:
67+
mirror-sourcehut:
7468
runs-on: ubuntu-latest
75-
timeout-minutes: 10
76-
if: vars.BITBUCKET_MIRROR_ENABLED == 'true'
69+
if: vars.SOURCEHUT_MIRROR_ENABLED == 'true'
7770
steps:
78-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
71+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
7972
with:
8073
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
8380
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
8890
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
92135
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

Comments
 (0)