feat(wiki): git-storage sync to Gitea (ADR-0015)
Wiki.js cannot reach git.lab from the cluster, so its content syncs to Gitea
(sorb/ThreadNetWiki) over HTTPS with a dedicated deploy PAT; a CI job canonizes
Gitea->git.lab (TURN-rotation pattern). The config job's ensure_git_storage
configures the git storage target (mode sync, config values {v:...}-encoded like
the auth strategy). Repo/user/branch/author are plain env; only the PAT lives in
the SOPS secret wikijs-git-secret, wired optional so the job still runs without it.
This commit is contained in:
@@ -202,6 +202,38 @@ def ensure_theming(jwt: str):
|
||||
log("Theming gesetzt (Dark-Default, Logo + Login-Hintergrund aus gemounteten Assets)")
|
||||
|
||||
|
||||
def ensure_git_storage(jwt: str):
|
||||
# Git-Storage: Wiki.js-Inhalt nach Gitea syncen (ADR-0015). Der Cluster erreicht
|
||||
# git.lab nicht -> Gitea ist das Ziel, ein CI-Job kanonisiert Gitea->git.lab.
|
||||
# Nur der PAT (GIT_STORAGE_TOKEN) ist ein Secret; Repo/User/Branch sind Klartext.
|
||||
# Fehlt der Token, wird der Schritt übersprungen -> der Job bleibt lauffähig, bevor
|
||||
# der Storage eingerichtet ist. Config-Werte brauchen die {"v":…}-Kodierung.
|
||||
token = os.environ.get("GIT_STORAGE_TOKEN", "").strip()
|
||||
repo = os.environ.get("GIT_STORAGE_REPO", "").strip()
|
||||
user = os.environ.get("GIT_STORAGE_USER", "").strip()
|
||||
if not (token and repo and user):
|
||||
log("Git-Storage übersprungen (GIT_STORAGE_TOKEN/REPO/USER nicht gesetzt)")
|
||||
return
|
||||
cfg = {
|
||||
"authType": "basic", "repoUrl": repo,
|
||||
"branch": os.environ.get("GIT_STORAGE_BRANCH", "main"),
|
||||
"basicUsername": user, "basicPassword": token, "verifySSL": True,
|
||||
"defaultEmail": os.environ.get("GIT_STORAGE_EMAIL", "wiki@localhost"),
|
||||
"defaultName": os.environ.get("GIT_STORAGE_NAME", "Wiki"),
|
||||
"sshPrivateKeyMode": "path", "localRepoPath": "./data/repo",
|
||||
"alwaysNamespace": False, "gitBinaryPath": "",
|
||||
}
|
||||
config = [{"key": k, "value": json.dumps({"v": v})} for k, v in cfg.items()]
|
||||
target = {"isEnabled": True, "key": "git", "mode": "sync",
|
||||
"syncInterval": "PT5M", "config": config}
|
||||
r = gql('mutation($t:[StorageTargetInput]!){storage{updateTargets(targets:$t)'
|
||||
'{responseResult{succeeded message}}}}',
|
||||
jwt, {"t": [target]})["storage"]["updateTargets"]["responseResult"]
|
||||
if not r["succeeded"]:
|
||||
sys.exit(f"Git-Storage fehlgeschlagen: {r['message']}")
|
||||
log(f"Git-Storage aktiviert (Gitea, sync): {repo}")
|
||||
|
||||
|
||||
def group_id(jwt: str, name: str):
|
||||
for g in gql("{groups{list{id name}}}", jwt)["groups"]["list"]:
|
||||
if g["name"] == name:
|
||||
@@ -248,6 +280,7 @@ def main():
|
||||
ensure_oidc(jwt)
|
||||
set_hide_local(jwt)
|
||||
ensure_theming(jwt)
|
||||
ensure_git_storage(jwt)
|
||||
log("fertig — Wiki.js konfiguriert")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user