Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mirror a GitHub repo using Github actions?

I would like to know if there is a way to use GitHub Actions to automatically mirror changes from repoA to repoB.

Both would be private repositories.
The workflow would be like this: a commit would be pushed to a branch on repoA and then automatically the same commit would be sent to repoB as well.

I've seen posts on adding a remote repository, but would be interested to see how GitHub Actions can help to improve this.

like image 925
RinW Avatar asked Jun 20 '20 00:06

RinW


People also ask

How do I mirror a GitHub repository?

Navigate to the repository you just cloned. Pull in the repository's Git Large File Storage objects. Mirror-push to the new repository. Push the repository's Git Large File Storage objects to your mirror.

What is mirroring Git?

Git mirroring is when a mirror copies the refs & the remote-tracking branches. It's supposed to be a functionally identical copy that is interchangeable with the original.

Is Git mirror two way?

No. Don't do that! Have your users add both repos as separate remotes to their local repos and give them a little shell-script or macro that converts git push into pushes to all currently available repos.

What does mirror mean in GitHub?

However, what we want with mirroring is to replicate the state of an origin repository (or upstream repository). By state, we mean all the branches (including master ) and all the tags as well. You'll need to do this when migrating your upstream repository to a new “home”, like when switching services like GitHub.


1 Answers

You might consider a GitHub Action like Git Sync:

A GitHub Action for syncing between two independent repositories using force push.

You add use in it an SSH private key to access to your second repository

ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}

(since you can create and store encrypted secrets in a workflow)

like image 173
VonC Avatar answered Oct 13 '22 11:10

VonC