Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
git-branch

GitHub Action

Mirror Branch

v1.0.3

Mirror Branch

git-branch

Mirror Branch

Mirror your new main branch to your old master branch (or mirror any branch A to any branch B)

Installation

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

              

- name: Mirror Branch

uses: zofrex/mirror-branch@v1.0.3

Learn more about this action in zofrex/mirror-branch

Choose a version

Mirror Branch action

Want to rename a branch? Want to rename it right now, but worried that it will break things that are pulling from its current name (e.g. CI jobs)?

Have you already renamed a branch and broken everything and you want to fix it ASAP?

This action updates another branch whenever you push to the branch it's triggered on. It should serve as a handy stopgap while you track down those last few jobs that are still set to the old name.

Inputs

target-branch

The name of the branch to update. Default "master".

force

Whether or not to force push. "true" means to force push, "false" means don't. Defaults to true.

Example usage

Mirror the release-candidate branch to the master branch:

name: Mirror branch

on:
  push:
    branches: [ release-candidate ]

jobs:
  mirror-to-master:
    runs-on: ubuntu-latest
    steps:
    - uses: zofrex/mirror-branch@v1

Mirror the release branch to the deployment branch, but don't force push:

name: Mirror branch

on:
  push:
    branches: [ release ]

jobs:
  mirror-to-master:
    runs-on: ubuntu-latest
    steps:
    - uses: zofrex/mirror-branch@v1
      with:
        target-branch: deployment

Note that the source branch to copy from is not an option for this action, so you should limit it to only run on one branch, unless you're absolutely certain that you want to mirror multiple branches to one target.