GitHub
GitHub Sync

GitHub Sync

Sync 2 repositories on push.

Generate Personal Access Token

The GitHub Account must have access to both repositories.

  1. Visit Token Settings (opens in a new tab)

  2. Generate a new token

    CleanShot 2022-10-03 at 21.46.07@2x.png

  3. Fill as below, this will be used to force push changes to the production repository

    CleanShot 2022-10-03 at 22.23.07@2x.png

  4. Copy the Personal Access Token and save it.

    CleanShot 2022-10-03 at 21.48.29@2x.png

Development Repository Setup

  1. Save this workflow as .github/workflows/git-sync.yml
.github/workflows/git-sync.yml
name: Git Sync
on:
  push:
    branches:
      - main
  workflow_dispatch:
jobs:
  git-sync:
    if: ${{ github.repository == 'username/dev-repo-name' }}
    runs-on: ubuntu-latest
    steps:
      - name: 🛑 Cancel Previous Runs
        uses: styfle/[email protected]
      - name: 🔗 Synchronize Repository
        uses: wei/git-sync@v3
        with:
          source_repo: 'https://username:${{ secrets.PAT }}@github.com/username/dev-repo-name.git'
          source_branch: 'main'
          destination_repo: 'https://username:${{ secrets.PAT }}@github.com/username/production-repo-name.git'
          destination_branch: 'main'
  1. Add PAT to the GitHub secrets

    Untitled

Production Repository Setup

No setup is needed.

Last updated on November 14, 2023