blob: ed94f14aa4b898445c5fed13c0e09506610b95fe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
name: Mirror Repository
on:
push:
branches:
- '**' # Trigger on push to any branch
delete:
branches:
- '**' # Trigger when branches are deleted
workflow_dispatch:
concurrency:
group: mirror-sync
cancel-in-progress: false
jobs:
mirror:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- name: GitLab
host: gitlab.com
repo: git@gitlab.com:slskd/slskd.git
- name: Codeberg
host: codeberg.org
repo: git@codeberg.org:slskd/slskd.git
fail-fast: false # Continue with other mirrors even if one fails
steps:
- name: Configure SSH
env:
SSH_KEY: ${{ secrets.GIT_MIRROR_SSH_KEY }}
run: |
if [ -z "$SSH_KEY" ]; then
echo "⚠️ SSH key not configured. Skipping mirror sync."
echo "Please set GIT_MIRROR_SSH_KEY secret to enable mirroring."
exit 1
fi
# Set up SSH key
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
# Start SSH agent and add key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Add known host to avoid SSH prompts
ssh-keyscan ${{ matrix.target.host }} >> ~/.ssh/known_hosts
# Configure Git
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Mirror to ${{ matrix.target.name }}
run: |
echo "🔄 Mirroring repository to ${{ matrix.target.name }}..."
# Clone the GitHub repository as a mirror (bare repo with all refs)
git clone --mirror https://github.com/${{ github.repository }}.git mirror-repo
cd mirror-repo
# Set the push URL to the target repository
git remote set-url --push origin ${{ matrix.target.repo }}
# Push everything to the mirror (handles all branches, tags, and deletions)
git push --mirror
echo "✅ Successfully mirrored to ${{ matrix.target.name }}"
|