A GitHub Action for mirroring a repository to another repository https://github.com/marketplace/actions/mirroring-repository
  • Shell 71.2%
  • Dockerfile 28.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Yuichi Goto 674e65a7d4
Merge pull request #20 from pixta-dev/remove-remote-branches
Remove remote branches after repository mirroring
2022-11-15 18:47:55 +09:00
.github/workflows Don't run tests 2 times in pull requests 2022-11-15 18:45:40 +09:00
action.yml initial commit 2019-09-26 19:06:35 +09:00
cleanup.sh Remove remote branches after repository mirroring 2022-11-15 15:57:54 +09:00
Dockerfile Remove remote branches after repository mirroring 2022-11-15 15:57:54 +09:00
LICENSE initial commit 2019-09-26 19:06:35 +09:00
mirror.sh Remove remote branches after repository mirroring 2022-11-15 15:57:54 +09:00
README.md Use actions/checkout@v3 in the example of README 2022-11-02 11:31:06 +09:00
setup-ssh.sh fix: don't throw error if .ssh exist 2020-12-21 12:05:49 -06:00

repository-mirroring-action

Test

A GitHub Action for mirroring a repository to another repository on GitHub, GitLab, BitBucket, AWS CodeCommit, etc.

This will copy all commits, branches and tags.

⚠️ Note that the other settings will not be copied. Please check which branch is 'default branch' after the first mirroring.

Usage

Customize following example workflow (namely replace <username>/<target_repository_name> with the right information) and save as .github/workflows/main.yml on your source repository.

To find out how to create and add the GITLAB_SSH_PRIVATE_KEY, follow the steps below:

  1. How to generate an SSH key pair. Recommended encryption would be at least 2048-bit RSA.
  2. Add the public key to your gitlab account
  3. Add the private key as a secret to your workflow. More information on creating and using secrets.
name: Mirroring

on: [push, delete]

jobs:
  to_gitlab:
    runs-on: ubuntu-latest
    steps:                                              # <-- must use actions/checkout before mirroring!
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: pixta-dev/repository-mirroring-action@v1
        with:
          target_repo_url:
            [email protected]:<username>/<target_repository_name>.git
          ssh_private_key:                              # <-- use 'secrets' to pass credential information.
            ${{ secrets.GITLAB_SSH_PRIVATE_KEY }}

  to_codecommit:                                        # <-- different jobs are executed in parallel.
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: pixta-dev/repository-mirroring-action@v1
        with:
          target_repo_url:
            ssh://git-codecommit.<somewhere>.amazonaws.com/v1/repos/<target_repository_name>
          ssh_private_key:
            ${{ secrets.CODECOMMIT_SSH_PRIVATE_KEY }}
          ssh_username:                                 # <-- (for codecommit) you need to specify ssh-key-id as ssh username.
            ${{ secrets.CODECOMMIT_SSH_PRIVATE_KEY_ID }}