https://github.com/plippe/github-fork-sync
https://github.com/plippe/github-fork-sync
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/plippe/github-fork-sync
- Owner: plippe
- License: unlicense
- Created: 2017-01-07T18:55:40.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-09-29T20:48:46.000Z (over 3 years ago)
- Last Synced: 2025-01-17T23:43:59.544Z (over 1 year ago)
- Language: Python
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# GitHub fork sync
> A fork is a copy of a repository. Forking a repository allows you to freely
> experiment with changes without affecting the original project.
>
> ...
>
> You might fork a project in order to propose changes to the upstream, or
> original, repository. In this case, it's good practice to regularly sync your
> fork with the upstream repository. To do this, you'll need to use Git on the
> command line. You can practice setting the upstream repository using the
> same octocat/Spoon-Knife repository you just forked!
>
> -- *[GitHub][1]*
Who has the time to manually sync their forks ? Don't waste time, automate this.
### GitHub token
First, you need a [GitHub token][2] to use their API. The token requires the
*repo* scope (Full control of private repositories). Store it and don't lose it.
### Run as a script
```
export GITHUB_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
python github_fork_sync.py --help
python github_fork_sync.py $UPSTREAM $FORK
```
Don't hesitate to add this as a cron job to have the sync run periodically.
### Run as an AWS Lambda
```
./aws/cloudformation.sh
# Create the stack
./aws/cloudformation.sh create $S3_BUCKET $S3_KEY $GITHUB_TOKEN
# Add repos to sync
./aws/cloudformation.sh add-sync $UPSTREAM1 $FORK1 $BRANCH1
./aws/cloudformation.sh add-sync $UPSTREAM2 $FORK2 $BRANCH2
./aws/cloudformation.sh add-sync $UPSTREAM3 $FORK3 $BRANCH3
# Delete the stack
./aws/cloudformation.sh delete $S3_BUCKET $S3_KEY
```
The lambda will be triggered daily for each repo.
[1]: https://help.github.com/articles/fork-a-repo/
[2]: https://help.github.com/articles/creating-an-access-token-for-command-line-use/