You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
Mirroring Branch
v5
This is a branch of pixta-dev/repository-mirroring-action that focuses on a specific repo branch, not the whole repo.
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.
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:
- How to generate an SSH key pair. Recommended encryption would be at least
2048-bit RSA
. - Add the public key to your gitlab account
- 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:
git@gitlab.com:<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 }}