docs: document github migration workflow and add adr 0005
- 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
This commit is contained in:
1 parent
acdd91dd10
commit
75a09f2ad8
2 files changed
+93
No files matched your search
@@ -21,6 +21,7 @@ Architecture Decision Records (ADRs) are maintained in [`docs/adr/`](docs/adr/):
|
||||
- [**ADR 002**: Environment Variables as Primary Configuration Interface with Pluggable Secret Resolvers](docs/adr/0002-environment-variables-as-primary-interface-with-sops-fallback.md)
|
||||
- [**ADR 003**: Dual-Forge Topology with Automated Push Mirroring and Retain-and-Report Error Policy](docs/adr/0003-dual-forge-topology-with-automated-push-mirroring.md)
|
||||
- [**ADR 004**: Existing Repository Linking and Auto-Detection](docs/adr/0004-existing-repository-linking-and-auto-detection.md)
|
||||
- [**ADR 005**: GitHub-to-Gitea Migration with Automated Push Mirroring](docs/adr/0005-github-to-gitea-migration-with-automated-push-mirroring.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -33,6 +34,7 @@ Arguments:
|
||||
name Optional repository name (defaults to current directory if omitted or '.')
|
||||
|
||||
Options:
|
||||
--migrate [URL] Migrate an existing GitHub repo to Gitea with automated push mirroring (URL or auto-detect from local origin)
|
||||
-p, --public Make repository public (default: private)
|
||||
-d, --description Optional repository description string
|
||||
-l, --license License template identifier (default: UNLICENSE, pass "" to disable)
|
||||
@@ -60,6 +62,13 @@ new-repo private-notes --no-mirror
|
||||
|
||||
# 5. Public open-source repository with MIT license
|
||||
new-repo utility-lib --public --license MIT
|
||||
|
||||
# 6. Migrate an existing GitHub repository to Gitea with push mirror
|
||||
new-repo --migrate https://github.com/my-org/existing-service
|
||||
|
||||
# 7. Migrate repository in-place from inside a local checkout
|
||||
cd ~/Projects/existing-service
|
||||
new-repo --migrate
|
||||
```
|
||||
|
||||
---
|
||||
@@ -140,6 +149,35 @@ sequenceDiagram
|
||||
end
|
||||
```
|
||||
|
||||
### Migration Workflow (`--migrate`)
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
autonumber
|
||||
actor User as Developer
|
||||
participant CLI as new-repo (--migrate)
|
||||
participant Gitea as Gitea API (Primary)
|
||||
participant GitHub as GitHub (Source)
|
||||
participant Git as Local Working Tree
|
||||
|
||||
User->>CLI: new-repo --migrate [github-target]
|
||||
CLI->>Gitea: GET /api/v1/repos/{user}/{repo} (Conflict Check)
|
||||
alt Repo Exists
|
||||
Gitea-->>CLI: 200 OK (Abort migration)
|
||||
else Repo Does Not Exist
|
||||
CLI->>Gitea: POST /api/v1/repos/migrate (mirror=False, auth_token=gh_token)
|
||||
Gitea->>GitHub: Server-to-server clone of branches, tags, and commits
|
||||
Gitea-->>CLI: Repository imported
|
||||
CLI->>Gitea: POST /api/v1/repos/{user}/{repo}/push_mirrors
|
||||
Gitea-->>CLI: Push mirror registered (sync on commit)
|
||||
opt Inside Local Git Repo
|
||||
CLI->>Git: Rename remote 'origin' -> 'github'
|
||||
CLI->>Git: Add remote 'origin' -> Gitea clone URL
|
||||
CLI->>Git: git branch --set-upstream-to=origin/<branch>
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Development & Quality Assurance
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
# 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:
|
||||
1. Replicated onto the private Gitea instance with complete commit history, branches, and tags.
|
||||
2. Configured with automated push mirroring so future commits pushed to Gitea automatically sync back to GitHub.
|
||||
3. 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`:
|
||||
|
||||
1. **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-repo` auto-detects the GitHub target from the local repository's `origin` remote.
|
||||
- Positional `name` argument can override the repository name on Gitea if desired.
|
||||
|
||||
2. **Pre-flight Conflict Validation**:
|
||||
- Before attempting migration, `new-repo` queries `GET /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.
|
||||
|
||||
3. **Server-Side Import via Gitea Migration API**:
|
||||
- Calls Gitea's `POST /api/v1/repos/migrate` with `service="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.
|
||||
|
||||
4. **Automated Push Mirror Registration**:
|
||||
- Unless `--no-mirror` is specified, registers the GitHub repository as a Gitea push mirror with `sync_on_commit: true` and an 8-hour sync interval.
|
||||
- This establishes Gitea as the authoritative primary forge and GitHub as the automated replica.
|
||||
|
||||
5. **Local Remote Reconfiguration**:
|
||||
- If executed inside a Git repository tracking the target GitHub repository:
|
||||
- Renames the existing `origin` remote to `github` (preserving direct access to the GitHub remote).
|
||||
- Sets Gitea as the new `origin` remote (`git@<gitea-host>:<user>/<repo>.git`).
|
||||
- Updates upstream tracking for the active branch (`git branch --set-upstream-to=origin/<branch> <branch>`).
|
||||
- If executed outside a Git repository, clones the newly created Gitea repository locally unless `--no-clone` is passed.
|
||||
|
||||
## 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 `github` remote 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:user` and `write:repository` scopes.
|
||||
|
||||
### Neutral
|
||||
- Standardizes on writable repository migration with reverse push mirroring rather than Gitea read-only pull mirrors.
|
||||
Reference in new issue
Block a user