Skip to main content

GitHub Sync

––– views

Sync 2 repositories on push.

Generate Personal Access Token

The GitHub Account must have access to both repositories.

  1. Visit Token Settings

  2. Generate a new token

    ![

    github-sync-1

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

    github-sync-2
  4. Copy the Personal Access Token and save it.

    github-sync-3

Development Repository Setup

  1. Save this workflow as .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/cancel-workflow-action@0.9.1 - 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'
yaml
  1. Add PAT to the GitHub secrets

    github-sync-4

Production Repository Setup

No setup is needed.