• Stars
    star
    249
  • Rank 159,856 (Top 4 %)
  • Language
    Shell
  • Created about 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Git Sync

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

Features

  • Sync branches between two GitHub repositories
  • Sync branches to/from a remote repository
  • GitHub action can be triggered on a timer or on push
  • To sync with current repository, please checkout Github Repo Sync

Usage

Always make a full backup of your repo (git clone --mirror) before using this action.

GitHub Actions

# .github/workflows/git-sync.yml

on: push
jobs:
  git-sync:
    runs-on: ubuntu-latest
    steps:
      - name: git-sync
        uses: wei/git-sync@v3
        with:
          source_repo: "source_org/repository"
          source_branch: "main"
          destination_repo: "destination_org/repository"
          destination_branch: "main"
          ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} # optional
          source_ssh_private_key: ${{ secrets.SOURCE_SSH_PRIVATE_KEY }} # optional, will override `SSH_PRIVATE_KEY`
          destination_ssh_private_key: ${{ secrets.DESTINATION_SSH_PRIVATE_KEY }} # optional, will override `SSH_PRIVATE_KEY`
Using shorthand

You can use GitHub repo shorthand like username/repository.

Using ssh

The ssh_private_key, or source_ssh_private_key and destination_ssh_private_key must be supplied if using ssh clone urls.

source_repo: "[email protected]:username/repository.git"

or

source_repo: "[email protected]:username/repository.git"
Using https

The ssh_private_key, source_ssh_private_key and destination_ssh_private_key can be omitted if using authenticated https urls.

source_repo: "https://username:[email protected]/username/repository.git"

Set up deploy keys

You only need to set up deploy keys if repository is private and ssh clone url is used.

  • Either generate different ssh keys for both source and destination repositories or use the same one for both, leave passphrase empty (note that GitHub deploy keys must be unique for each repository)
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
  • In GitHub, either:

    • add the unique public keys (key_name.pub) to Repo Settings > Deploy keys for each repository respectively and allow write access for the destination repository

    or

    • add the single public key (key_name.pub) to Personal Settings > SSH keys
  • Add the private key(s) to Repo > Settings > Secrets for the repository containing the action (SSH_PRIVATE_KEY, or SOURCE_SSH_PRIVATE_KEY and DESTINATION_SSH_PRIVATE_KEY)

Advanced: Sync all branches

To Sync all branches from source to destination, use source_branch: "refs/remotes/source/*" and destination_branch: "refs/heads/*". But be careful, branches with the same name including master will be overwritten.

source_branch: "refs/remotes/source/*"
destination_branch: "refs/heads/*"

Advanced: Sync all tags

To Sync all tags from source to destination, use source_branch: "refs/tags/*" and destination_branch: "refs/tags/*". But be careful, tags with the same name will be overwritten.

source_branch: "refs/tags/*"
destination_branch: "refs/tags/*"

Docker

$ docker run --rm -e "SSH_PRIVATE_KEY=$(cat ~/.ssh/id_rsa)" $(docker build -q .) \
  $SOURCE_REPO $SOURCE_BRANCH $DESTINATION_REPO $DESTINATION_BRANCH

Author

Wei He [email protected]

License

MIT

More Repositories

1

pull

🤖 Keep your forks up-to-date via automated PRs
JavaScript
5,890
star
2

socialify

💞 Socialify your project. 🌐 Share with the world!
TypeScript
1,777
star
3

curl

Wraps the curl CLI to be used in Github Actions
Dockerfile
109
star
4

baota

宝塔 Linux 面板 最新版本与历史存档
106
star
5

rclone

Wraps the rclone CLI to be used in Github Actions
Dockerfile
74
star
6

wget

Wraps the wget CLI to be used in Github Actions
Dockerfile
30
star
7

new-issue

A fully customizable Github issues interface. Setup for your repo today!
JavaScript
22
star
8

discord-actions-bot

🤖 A Discord Bot that helps with Action Items.
JavaScript
18
star
9

minifier

⚡️ Offline-first web app for an HTML, JS, CSS minifier.
JavaScript
17
star
10

github-project-notifier

A Discord 🤖 that notifies on GitHub Project Card updates
JavaScript
9
star
11

wei

👨‍💻 Full Stack Engineer + ☁️ Solutions Architect Expert + 💼 M.B.A.
HTML
9
star
12

cloudcone-cli

Cloudcone commandline tool
Shell
6
star
13

ssr-scraper

Scrapes all devtip/ssr_subscrible_tool forks to find good servers.
JavaScript
3
star
14

ghw-gpg

Prove yourself with GPG
3
star
15

ROT47

Node Tool for ROT47 https://rot47.net
JavaScript
3
star
16

WHRoundedImageView

A derived UIImageView class to render a rounded image with radius and border options.
Swift
3
star
17

dotfiles

@wei does dotfiles
Shell
2
star
18

amplify-js-7049

Attempt to reproduce aws-amplify/amplify-js#7049
JavaScript
2
star
19

flask-blog

Python
2
star
20

nyancat-server

Docker Image for klange/nyancat telnet server.
C
2
star
21

amplify-js-6693-react

Reproduce aws-amplify/amplify-js#6693 for React
JavaScript
1
star
22

action-demo

1
star
23

aws-amplify-react

Template used to reproduce amplify-js react issues
JavaScript
1
star
24

reviewing-a-pull-request

HTML
1
star
25

test-pr

1
star
26

fb-ad-preview-issue

Reproduce Facebook Bug
Shell
1
star
27

heroku-buildpack-static

Fork of heroku/heroku-buildpack-static
Ruby
1
star