A GitHub Action for syncing the current repository using force push.
- Sync branches between two GitHub repositories
- Sync branches from a remote repository
- GitHub action can be triggered on a timer or on push
- To push to a remote repository, please checkout git-sync
- Support syncing tags.
Create a Personal Access Token at your Github account settings ( link ).
The Personal Access Token has to have permission over both repositories being synced, and it has to have the following permissions:
- Contents: Read and write
- Workflows: Read and write
- Metadata: Read only
Finally, go to the synced repo, Settings -> Secrets and variables -> Actions
and add a new secret called PAT
.
# File: .github/workflows/repo-sync.yml
on:
schedule:
- cron: "*/15 * * * *"
workflow_dispatch:
jobs:
repo-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: repo-sync
uses: repo-sync/github-sync@v2
with:
source_repo: ""
source_branch: ""
destination_branch: ""
github_token: ${{ secrets.PAT }}
If source_repo
is private or with another provider, either (1) use an authenticated HTTPS repo clone url like https://${access_token}@github.com/owner/repository.git
or (2) set a SSH_PRIVATE_KEY
secret environment variable and use the SSH clone url
- Make a backup
- Create a new branch in your repo (destination repo), it should not share the name with any branch in source repo
- Make the new branch the default branch under repo settings
- Use
*
for bothsource_branch
anddestination_branch
- Optionally, you can force sync all tags:
with: sync_tags: "true"
This will force sync ALL branches to match source repo. Branches that are created only in the destination repo will not be affected but all the other branches will be hard reset to match source repo.
Thanks goes to these wonderful people (emoji key):
Wei He 💻 📖 🎨 🤔 |
Zeke Sikelianos 📖 🤔 |
Alex Page 🐛 |
xtqqczze 💻 📖 |
Kay Harrison-Sims 🐛 |
Gibby 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!