Why ?
What I’m trying to accomplish is a fail-safe in case something happens to GitHub which would make me loose access, be that voluntarily or involuntarily.
I am not migrating away from GitHub because I see no reason to: the platform is very useful to me, and I’d not like to loose it.
Why Gitea
I’d like a Web UI onto these repositories in addition to the files in the file system. It could have been Gitlab, but I think Gitea is probably the option with the lowest resource requirements.
When I add a repository to Gitea and specify I want it to be mirrored, Gitea will take charge of periodically querying the source repository and pulling changes in it.
How To ?
After setting up Gitea and creating a user, I create an API token in Gitea with which I can create repositories programmatically.
Then you will also need to create a Personal Access Token In Github with the below scope
- Select public_repo scope if you just want to mirror Public Gist / Repo to your mirror
- Select repo scope if you want to mirror both public & private Gist / Repo to your mirror
- Select gist scope if you want to mirror private gists.
Installation
- Install Python3
sudo apt-get install python3
- Install PIP3
sudo apt-get install python3-pip
- Install PyGithub
pip install PyGithub
Once everything is installed.
Clone / Download this repo https://github.com/varunsridharan/github-gitea-mirror
And update src/config.json
with your information And run the below cmd
Mirror Everything
Below CMD Will mirror (Public / Private ) Repository, Gists Forks & Stared Repos
python3 mirror.py
Mirror Source Gists
python3 gist.py
Mirror Stared Gists
python3 giststared.py
Mirror Source Repository
python3 repoSource.py
Mirror Forked Repository
python3 repoForked.py
Mirror Stared Repository
python3 repoStared.py
varunsridharan / github-gitea-mirror
Simple Python Script To Mirror Repository From Github To Gitea
Simple Python Script To Mirror Repository / Gist From Github To Gitea
Why ?
I am a data hoarder.
I am not migrating away from GitHub because I see no reason to: the platform is very useful to me, and I’d not like to lose it. What I’m trying to accomplish is a fail-safe in case something happens to GitHub which would make me lose access, be that voluntarily or involuntarily.
✅ Requirements
- Python3 --
sudo apt-get install python3
-
PyGithub --
pip install PyGithub
⚙️Installation
Github Clone
Just run the below cmd in your Gitea server
git clone https://github.com/varunsridharan/github-gitea-mirror
Or you can download the source code and install it where ever you need
🚀 Usage
Github Access Token Scopes
- if you want to mirror private repos then select everything under Repo scope
- if you want to mirror public repos then select repo.public_repo scope
- if you want to mirror secret Gists…
Top comments (0)