Automatic sync with GitLab's read-only mirror #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automatic sync with GitLab's read-only mirror | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '42 0 * * 0' | |
workflow_dispatch: | |
jobs: | |
mirror: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
repo: | |
- {github: "https://github.com/rehlds/.github.git", gitlab: "[email protected]:rehlds/dot-github.git"} | |
- {github: "https://github.com/rehlds/rehlds.git", gitlab: "[email protected]:rehlds/rehlds.git"} | |
steps: | |
- name: Set up SSH key | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.GITLAB_DEPLOY_KEY }} | |
run: | | |
mkdir -p ~/.ssh | |
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519 | |
chmod 600 ~/.ssh/id_ed25519 | |
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 GitLab | |
run: | | |
cd repo-mirror | |
git remote set-url origin ${{ matrix.repo.gitlab }} | |
git push --mirror |