A GitHub Action for mirroring a git repository to another location via SSH.
Required SSH URL of the source repo.
Required SSH URL of the destination repo.
SSH_PRIVATE_KEY
: Create a SSH key without a passphrase which has access to both repositories. On GitHub you can add the public key as a deploy key to the repository. GitLab has also deploy keys with write access and for any other services you may have to add the public key to your personal account.
Store the private key as an encrypted secret and use it in your workflow as seen in the example workflow below.
If you added the private key in an environment make sure to reference the environment name in your workflow otherwise the secret is not passed to the workflow.
name: Mirror to Bitbucket Repo
on: [ push, delete, create ]
# Ensures that only one mirror task will run at a time.
concurrency:
group: git-mirror
jobs:
git-mirror:
runs-on: ubuntu-latest
steps:
- uses: wearerequired/git-mirror-action@v1
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
with:
source-repo: "[email protected]:wearerequired/git-mirror-action.git"
destination-repo: "[email protected]:wearerequired/git-mirror-action.git"
docker run --rm -e "SSH_PRIVATE_KEY=$(cat ~/.ssh/id_rsa)" $(docker build -q .) "$SOURCE_REPO" "$DESTINATION_REPO"
The Dockerfile and associated scripts and documentation in this project are released under the MIT License.