pixta-dev repository-mirroring-action

repository·main·Indexed 42 days ago

https://github.com/pixta-dev/repository-mirroring-action

A GitHub Action to mirror a repository's entire history, including all commits, branches, and tags, to remote platforms such as GitLab, BitBucket, or AWS CodeCommit. Requires actions/checkout with fetch-depth: 0 and supports SSH authentication via target_repo_url, ssh_private_key, and ssh_username.

Tokens
754
Snippets
2
Records
3
Agent score
5%

What's inside repository-mirroring-action

  1. Mirror a repository using repository-mirroring-action

    main

    Use pixta-dev/repository-mirroring-action to mirror all commits, branches, and tags from your source repository to a target repository on platforms like GitHub, GitLab, BitBucket, or AWS CodeCommit.

    Important Considerations:

    • Settings: Only commits, branches, and tags are copied. Other repository settings (like branch protection rules or webhooks) will not be mirrored.
    • Default Branch: You must manually verify which branch is set as the 'default branch' on the target repository after the first mirroring operation.
    • Checkout Requirement: You must use actions/checkout with fetch-depth: 0 before calling this action to ensure all history is available for mirroring.
    name: Mirroring
    
    on: [push, delete]
    
    jobs:
      to_target:
        runs-on: ubuntu-latest
        steps:
          - 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: ${{ secrets.TARGET_SSH_PRIVATE_KEY }}
  2. Set up SSH authentication for GitLab mirroring

    main

    To mirror to GitLab, you must set up SSH keys:

    1. Generate an SSH key pair: Use at least 2048-bit RSA encryption.
    2. Add Public Key: Add the public key to your GitLab account profile under SSH Keys.
    3. Add Private Key to GitHub: Add the private key as a GitHub Action Secret (e.g., named GITLAB_SSH_PRIVATE_KEY) so the workflow can access it securely.
  3. Configure repository-mirroring-action inputs

    main

    The action accepts the following inputs to define the target destination and authentication:

    • target_repo_url: The SSH URL of the target repository (e.g., git@gitlab.com:user/repo.git or an AWS CodeCommit SSH URL).
    • ssh_private_key: The SSH private key used for authentication. It is highly recommended to pass this via GitHub Secrets (e.g., ${{ secrets.SSH_PRIVATE_KEY }}).
    • ssh_username: Required specifically for AWS CodeCommit. You must provide the ssh-key-id as the username.
    # Example for AWS CodeCommit
    - uses: pixta-dev/repository-mirroring-action@v1
      with:
        target_repo_url: ssh://git-codecommit.<region>.amazonaws.com/v1/repos/<target_repository_name>
        ssh_private_key: ${{ secrets.CODECOMMIT_SSH_PRIVATE_KEY }}
        ssh_username: ${{ secrets.CODECOMMIT_SSH_PRIVATE_KEY_ID }}