caddy-git-server
Caddy module that provides a git server.
import requests
import os
target_dir = "/home/rex/projects/caddy-git-server/srv/git/"
skip_list = [
"Gokucraft",
"micropython",
"rex--.github.io",
"gomap",
"test",
"verbose-meme",
"mkc"
]
TOKEN = "ghp_GITHUB_ACCESS_TOKEN"
headers = {
"Accept": "applicaton/vnd.github+json",
"Authorization": "Bearer " + TOKEN,
"X-GitHub-Api-Version": "2026-03-10",
}
r = requests.get("https://api.github.com/user/repos?per_page=100&type=owner", headers=headers)
repo_list = r.json()
print("Found %i repositories" % len(repo_list))
for repo in repo_list:
name = repo["name"]
full_name = repo["full_name"]
clone_url = "https://"+TOKEN+"@github.com/"+full_name+".git" #repo["clone_url"]
description = repo["description"]
is_fork = repo["fork"]
is_private = repo["private"]
owner = repo["owner"]["login"]
repo_path = target_dir + name + ".git"
if (name not in skip_list):
print("Mirroring %s -> %s %s" % (full_name, name, is_private))
listed = ""
if not is_private:
listed = " --config caddy-git-server.listed=true"
os.system('git clone --mirror%s %s %s' % (listed, clone_url, repo_path))
if description is not None:
os.system('echo -e "%s" > %s/description' % (description, repo_path))