Simple Python Script To Mirror Repository From Github To Gitea
Go to file
2023-01-28 07:44:51 +05:30
.github/workflows 💬 - Files Synced | Github Action Runner : 46 | Triggered By varunsridharan/.workflows@c283f7118d 2021-04-30 01:07:05 +00:00
src Update repositoryStared.py 2023-01-28 07:44:51 +05:30
.gitattributes Added 2 files 2020-10-12 19:02:52 +05:30
.gitignore Added 2 files 2020-10-12 19:02:52 +05:30
bulk-update-github-auth-token.py Added Bulk Token Updater 2020-10-25 20:23:20 +05:30
CHANGELOG.md V1.3 2021-03-30 07:50:18 +05:30
gist.py Improved 2020-10-13 10:53:34 +05:30
giststared.py Improved 2020-10-13 10:53:34 +05:30
LICENSE Create LICENSE 2020-10-25 07:02:45 +05:30
mirror.py Updated 2020-10-13 11:05:16 +05:30
README.md Add a blacklist for repositories 2022-05-17 15:23:18 +01:00
repoForked.py Updated 2020-10-13 11:05:16 +05:30
repoSource.py Updated 2020-10-13 11:05:16 +05:30
repoStared.py Updated 2020-10-13 11:05:16 +05:30

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 Id not like to lose it. What Im 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

  1. Python3 -- sudo apt-get install python3
  2. 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 then select gist scope

First make sure you have updated the config.json

Option Description
github.username Your Github Username
github.accesstoken Your Github Account's Personal Access Token
- -
gitea.host Selfhosted Gitea URL without / at the end
gitea.accesstoken Your Personal Access Token
gitea.username Account User Name
gitea.gist.prefix Custom Prefix For Repository When Mirroring Gists
gitea.gist.surfix Custom Prefix For Repository When Mirroring Gists
- -
repomap Remap A Repository To Diff User
blacklist A list of glob-expression on github full repository names to skip
gistsSource set to true to mirror all Gists Created By You
gistsStared set to true to mirror all Gists Stared By You
repositoryStared set to true to mirror all Repository Stared By You
repositorySource set to true to mirror all Repository Created By You
repositoryForked set to true to mirror all Repository Forked By You
- -
local_cache.enabled Set to true to store all repostiory slugs from gitea as json
local_cache.file_path Custom Path to store json file

Local Cache can come handly when running this script via cron which reduces api request your selfhosted gitea instance

Run cmd & Wait

$ python3 mirror.py

Cron Setup

  1. Run crontab -e
  2. mkdir $HOME/mirrorLogs -p
  3. /usr/bin/python3 $HOME/github-to-gitea-mirror/mirror.py > $HOME/mirrorLogs/date +%Y-%m-%d-%H-%M-%S.log 2>&1

📝 Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Checkout CHANGELOG.md

🤝 Contributing

If you would like to help, please take a look at the list of issues.

💰 Sponsor

I fell in love with open-source in 2013 and there has been no looking back since! You can read more about me here. If you, or your company, use any of my projects or like what Im doing, kindly consider backing me. I'm in this for the long run.

  • How about we get to know each other over coffee? Buy me a cup for just $9.99
  • How about buying me just 2 cups of coffee each month? You can do that for as little as $9.99
  • 🔰 We love bettering open-source projects. Support 1-hour of open-source maintenance for $24.99 one-time?
  • 🚀 Love open-source tools? Me too! How about supporting one hour of open-source development for just $49.99 one-time ?

📜 License & Conduct

📣 Feedback

  • This repository if this project helped you! 😉
  • Create An 🔧 Issue if you need help / found a bug

Connect & Say 👋


Built With ♥ By Varun Sridharan 🇮🇳