Skip to content
copy

GitHub Action

Sync Git Branch Action

v1.0.0 Latest version

Sync Git Branch Action

copy

Sync Git Branch Action

Action for synchronizing a git branch to another location (Bitbucket, GitHub, GitLab, etc.) using SSH

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Sync Git Branch Action

uses: zent-contrib/[email protected]

Learn more about this action in zent-contrib/sync-git-branch

Choose a version

Sync Git Branch Action

A GitHub Action for synchronizing a git branch to another location via SSH.

Inputs

Name Description Default Required
source-branch Branch name in the source repository Yes
destination-repo SSH URL of the destination repository Yes
source-repo SSH URL of the source repository The respository this action runs in No
destination-branch Branch name in the destination repository Same as source-branch No

Environment variables

SSH_PRIVATE_KEY: Create a SSH key without a passphrase which has access to both repositories.

On GitHub you should add the public key to repository "deploy keys".

Store the private key as a secret and use it in your workflow as seen in the example usage below.

Example workflow

name: Sync main branch to Bitbucket

on: [push, delete, create]

jobs:
  git-mirror:
    runs-on: ubuntu-latest
    steps:
      - uses: zent-contrib/git-branch-sync-action@v1
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
        with:
          source-branch: main
          destination-repo: "[email protected]:<org>/<repo>.git"