Skip to content

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

License

Notifications You must be signed in to change notification settings

yesolutions/mirror-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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@v3
          with:
            fetch-depth: 0
        - uses: yesolutions/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 and GIT_SSH_KNOWN_HOSTS

      steps:
        - uses: actions/checkout@v3
          with:
            fetch-depth: 0
        - uses: yesolutions/mirror-action@master
          with:
            REMOTE: 'ssh://[email protected]/spyoungtech/mirror-action.git'
            GIT_SSH_PRIVATE_KEY: ${{ secrets.GIT_SSH_PRIVATE_KEY }}
            GIT_SSH_KNOWN_HOSTS: ${{ secrets.GIT_SSH_KNOWN_HOSTS }}

GIT_SSH_KNOWN_HOSTS is expected to be the contents of a known_hosts file.

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@v3
          with:
            fetch-depth: 0
        - uses: yesolutions/mirror-action@master
          with:
            REMOTE: [email protected]/spyoungtech/mirror-action.git
            GIT_SSH_PRIVATE_KEY: ${{ secrets.GIT_SSH_PRIVATE_KEY }}
            GIT_SSH_NO_VERIFY_HOST: "true"

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published