Skip to content

Warning

You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

mirror-repository

Actions
Automate mirroring of git commits to or from a remote repository, like GitLab, Bitbucket, or another GitHub repository
v0.4.0
Verified creator
Star (99)

Verified

GitHub has manually verified the creator of the action as an official partner organization. For more info see About badges in GitHub Marketplace.

mirror-action

A GitHub Action for mirroring your commits to a different remote repository

This project is mirrored on GitLab

Example workflows

Mirror a repository with username/password over HTTPS

For example, this project uses the following workflow to mirror from GitHub to GitLab

on: [push]
  ...
      steps:
        - uses: actions/checkout@v1
        - uses: spyoungtech/mirror-action@master
          with:
            REMOTE: 'https://gitlab.com/spyoungtech/mirror-action.git'
            GIT_USERNAME: spyoungtech
            GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }}

Be sure to set the GIT_PASSWORD secret in your repo secrets settings.

NOTE: by default, all branches are pushed. If you want to avoid this behavior, set PUSH_ALL_REFS: "false"

You can further customize the push behavior with the GIT_PUSH_ARGS parameter. By default, this is set to --tags --force --prune

If something goes wrong, you can debug by setting DEBUG: "true"

Mirror a repository using SSH

Requires version 0.4.0+

Pretty much the same, but using GIT_SSH_PRIVATE_KEY, GIT_SSH_PUBLIC_KEY, and GIT_SSH_KNOWN_HOSTS

      steps:
        - uses: actions/checkout@v1
        - uses: spyoungtech/mirror-action@master
          with:
            REMOTE: 'ssh://git@gitlab.com/spyoungtech/mirror-action.git'
            GIT_SSH_PRIVATE_KEY: ${{ secrets.GIT_SSH_PRIVATE_KEY }}
            GIT_SSH_PUBLIC_KEY: ${{ secrets.GIT_SSH_PUBLIC_KEY }}
            GIT_SSH_KNOWN_HOSTS: ${{ secrets.GIT_SSH_KNOWN_HOSTS }}

Be sure you set the secrets in your repo secrets settings!

NOTE: if you prefer to skip hosts verification instead of providing a known_hosts file, you can do so by using the GIT_SSH_NO_VERIFY_HOST input option. e.g.

      steps:
        - uses: actions/checkout@v1
        - uses: spyoungtech/mirror-action@master
          with:
            REMOTE: git@gitlab.com/spyoungtech/mirror-action.git
            GIT_SSH_PRIVATE_KEY: ${{ secrets.GIT_SSH_PRIVATE_KEY }}
            GIT_SSH_PUBLIC_KEY: ${{ secrets.GIT_SSH_PUBLIC_KEY }}
            GIT_SSH_NO_VERIFY_HOST: "true"

WARNING: this setting is a compromise in security. Using known hosts is recommended.

mirror-repository is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Automate mirroring of git commits to or from a remote repository, like GitLab, Bitbucket, or another GitHub repository
v0.4.0

Verified

GitHub has manually verified the creator of the action as an official partner organization. For more info see About badges in GitHub Marketplace.

mirror-repository is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.