aboutsummaryrefslogtreecommitdiffstats
path: root/.github
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-11-22 15:28:14 -0600
committerJP Dillingham <jp@dillingham.me>2025-11-22 15:28:14 -0600
commitce6a9863bd5824e326b8760576fc1c67c8129894 (patch)
tree84b69499ea40aa81f4edd55e3dd6807de838c12d /.github
parentf310639e80b2403ec64c5e54a987593c09538f17 (diff)
downloadslskd-ce6a9863bd5824e326b8760576fc1c67c8129894.tar.gz
add mirror workflow
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/mirror.yml87
1 files changed, 87 insertions, 0 deletions
diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml
new file mode 100644
index 00000000..d20d0e2c
--- /dev/null
+++ b/.github/workflows/mirror.yml
@@ -0,0 +1,87 @@
+name: Mirror Repository
+
+on:
+ push:
+ branches:
+ - '**' # Trigger on push to any branch
+ delete:
+ branches:
+ - '**' # Trigger when branches are deleted
+
+jobs:
+ mirror:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0 # Fetch full history for proper mirroring
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - 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
+
+ # Add known hosts to avoid SSH prompts
+ ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
+ ssh-keyscan codeberg.org >> ~/.ssh/known_hosts
+
+ # Configure Git
+ git config --global user.name "GitHub Actions"
+ git config --global user.email "actions@github.com"
+
+ - name: Mirror to GitLab
+ run: |
+ echo "🔄 Syncing to GitLab..."
+ # Add GitLab remote with SSH
+ git remote add gitlab git@gitlab.com:slskd/slskd.git
+
+ # Push all branches and tags to GitLab
+ git push gitlab --all --force
+ git push gitlab --tags --force
+
+ echo "✅ Successfully synced to GitLab"
+
+ - name: Mirror to Codeberg
+ run: |
+ echo "🔄 Syncing to Codeberg..."
+ # Add Codeberg remote with SSH
+ git remote add codeberg git@codeberg.org:slskd/slskd.git
+
+ # Push all branches and tags to Codeberg
+ git push codeberg --all --force
+ git push codeberg --tags --force
+
+ echo "✅ Successfully synced to Codeberg"
+
+ - name: Handle branch deletion
+ if: github.event_name == 'delete' && github.event.ref_type == 'branch'
+ run: |
+ DELETED_BRANCH="${{ github.event.ref }}"
+ echo "🗑️ Branch '$DELETED_BRANCH' was deleted, syncing deletion to mirrors..."
+
+ # Delete branch from GitLab
+ git push git@gitlab.com:slskd/slskd.git --delete "$DELETED_BRANCH" || echo "Branch may not exist on GitLab"
+
+ # Delete branch from Codeberg
+ git push git@codeberg.org:slskd/slskd.git --delete "$DELETED_BRANCH" || echo "Branch may not exist on Codeberg"
+
+ - name: Summary
+ run: |
+ echo "🎉 Repository mirroring completed!"
+ echo "📊 Summary:"
+ echo " - GitHub: ✅ Source repository"
+ echo " - GitLab: ✅ Synced"
+ echo " - Codeberg: ✅ Synced" \ No newline at end of file