- Add ADR 0005 detailing GitHub-to-Gitea migration design decisions and trade-offs - Update README.md with --migrate flag specifications, examples, and Mermaid sequence diagram
3.7 KiB
ADR 005: GitHub-to-Gitea Migration with Automated Push Mirroring
Status
Accepted (2026-10-10)
Context
Developers frequently have existing repositories hosted on GitHub—either legacy projects created before establishing a sovereign homelab forge, forks of upstream codebases, or collaborative work.
To integrate these projects into the sovereign dual-forge architecture, the repository must be:
- Replicated onto the private Gitea instance with complete commit history, branches, and tags.
- Configured with automated push mirroring so future commits pushed to Gitea automatically sync back to GitHub.
- Linked locally so active development targets Gitea as the primary remote (
origin) while retaining GitHub as a secondary remote.
Performing these steps manually involves navigating web UIs, copying tokens, configuring mirror settings, and executing manual Git remote renames and upstream branch tracking commands. Furthermore, performing the import via client-side clone and push consumes client storage and upload bandwidth.
Decision
We introduce a dedicated --migrate [GITHUB_URL] option to new-repo:
-
Target Parsing & Auto-Detection:
- Accepts HTTPS URLs (
https://github.com/owner/repo), SSH URLs (git@github.com:owner/repo.git), and shorthands (owner/repo). - If the target URL is omitted,
new-repoauto-detects the GitHub target from the local repository'soriginremote. - Positional
nameargument can override the repository name on Gitea if desired.
- Accepts HTTPS URLs (
-
Pre-flight Conflict Validation:
- Before attempting migration,
new-repoqueriesGET /api/v1/repos/{owner}/{name}on Gitea. - If a repository with the same name already exists on Gitea, the migration aborts immediately with an informative error to prevent overwriting or state corruption.
- Before attempting migration,
-
Server-Side Import via Gitea Migration API:
- Calls Gitea's
POST /api/v1/repos/migratewithservice="github",mirror=False, and the GitHub personal access token. - Gitea performs a direct server-to-server clone of all branches, tags, and commit history without routing data through the local machine.
- Calls Gitea's
-
Automated Push Mirror Registration:
- Unless
--no-mirroris specified, registers the GitHub repository as a Gitea push mirror withsync_on_commit: trueand an 8-hour sync interval. - This establishes Gitea as the authoritative primary forge and GitHub as the automated replica.
- Unless
-
Local Remote Reconfiguration:
- If executed inside a Git repository tracking the target GitHub repository:
- Renames the existing
originremote togithub(preserving direct access to the GitHub remote). - Sets Gitea as the new
originremote (git@<gitea-host>:<user>/<repo>.git). - Updates upstream tracking for the active branch (
git branch --set-upstream-to=origin/<branch> <branch>).
- Renames the existing
- If executed outside a Git repository, clones the newly created Gitea repository locally unless
--no-cloneis passed.
- If executed inside a Git repository tracking the target GitHub repository:
Consequences
Good
- Zero Client Bandwidth Overhead: Full repository history, branches, and tags transfer directly between GitHub and Gitea servers.
- Atomic Topology Transition: Converts a GitHub-only repository into a sovereign dual-forge topology with push mirroring in a single command.
- Preserved Remote Access: Retaining GitHub as
githubremote maintains convenient access to GitHub-specific tooling or secondary remotes. - Fail-Safe Conflict Protection: Pre-flight existence checks prevent accidental destructive overwrites.
Bad
- Requires a GitHub personal access token with repository read permissions and a Gitea token with
write:userandwrite:repositoryscopes.
Neutral
- Standardizes on writable repository migration with reverse push mirroring rather than Gitea read-only pull mirrors.