Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 2.73 KB

README.md

File metadata and controls

61 lines (47 loc) · 2.73 KB

branch-mirroring-action

This is a fork originating from the pixta-dev/repository-mirroring-action that focuses on a specific repo branch, not the whole repo.

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: RediSearch/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 }}
          source_branch_id:
            ${{ github.ref_name }}   

  to_codecommit:                                        # <-- different jobs are executed in parallel.
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: RediSearch/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 }}
          source_branch_id:
            ${{ github.ref_name }}