Skip to content

Automatic sync with read-only mirrors #4

Automatic sync with read-only mirrors

Automatic sync with read-only mirrors #4

name: Automatic sync with read-only mirrors
on:
# push:
# branches:
# - main
schedule:
- cron: '42 0 * * 0'
workflow_dispatch:
jobs:
mirror:
runs-on: ubuntu-latest
strategy:
matrix:
repo:
# - {github: "", bitbucket: "", codeberg: "", gitlab: "" }
- {github: "https://github.com/ZXCmod/.github.git", bitbucket: "git@bitbucket.org:zxcmod/.github.git", codeberg: "git@codeberg.org:ZXCmod/.github.git", gitlab: "git@gitlab.com:zxcmod/dot-github.git"}
- {github: "https://github.com/ZXCmod/ZXCmod.git", bitbucket: "git@bitbucket.org:zxcmod/ZXCmod.git", codeberg: "git@codeberg.org:ZXCmod/ZXCmod.git", gitlab: "git@gitlab.com:zxcmod/ZXCmod.git"}
steps:
- name: Set up SSH key
env:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -t rsa,ed25519 bitbucket.org >> ~/.ssh/known_hosts
ssh-keyscan -t rsa,ed25519 codeberg.org >> ~/.ssh/known_hosts
ssh-keyscan -t rsa,ed25519 github.com >> ~/.ssh/known_hosts
ssh-keyscan -t rsa,ed25519 gitlab.com >> ~/.ssh/known_hosts
- name: Clone repository as mirror
run: |
git clone --mirror ${{ matrix.repo.github }} repo-mirror
- name: Push to BitBucket
run: |
cd repo-mirror
git remote set-url origin ${{ matrix.repo.bitbucket }}
git push --mirror --force
- name: Push to CodeBerg
run: |
cd repo-mirror
git remote set-url origin ${{ matrix.repo.codeberg }}
git push --mirror --force
- name: Push to GitLab
run: |
cd repo-mirror
git remote set-url origin ${{ matrix.repo.gitlab }}
git push --mirror --force