make allowed_owners, git name/email configurable per instance
Hardcoded ALLOWED_OWNER="euphon" blocked non-euphon repos from being processed. Move it to config.yaml as a list so each deployment can specify its own allowed owners. Also make git user.name/email configurable for multi-instance deployments (e.g. ms vs yoyo).
This commit is contained in:
parent
ff2fe9a244
commit
dffdbf54f5
@ -13,6 +13,9 @@ WEBHOOK_SECRET: str = _cfg["gitea"].get("webhook_secret", "")
|
||||
BOT_USERNAME: str = _cfg["bot"]["username"]
|
||||
LISTEN_PORT: int = _cfg["bot"].get("listen_port", 9880)
|
||||
WORKSPACE_DIR: Path = Path(_cfg["bot"].get("workspace_dir", "/data/src/gitea-bot/workspaces"))
|
||||
BOT_GIT_NAME: str = _cfg["bot"].get("git_name", BOT_USERNAME)
|
||||
BOT_GIT_EMAIL: str = _cfg["bot"].get("git_email", f"{BOT_USERNAME}@euphon.net")
|
||||
ALLOWED_OWNERS: list[str] = _cfg["bot"].get("allowed_owners", [])
|
||||
|
||||
# Claude
|
||||
CLAUDE_COMMAND: str = _cfg["claude"]["command"]
|
||||
|
||||
3
main.py
3
main.py
@ -15,7 +15,6 @@ log = logging.getLogger("gitea-bot")
|
||||
|
||||
gitea = GiteaClient()
|
||||
|
||||
ALLOWED_OWNER = "euphon"
|
||||
MAX_RESPONSE_LEN = 60000
|
||||
CLAUDE_TIMEOUT = 3600 # 60 minutes
|
||||
app = FastAPI()
|
||||
@ -223,7 +222,7 @@ async def webhook(request: Request):
|
||||
owner = repo_data.get("owner", {}).get("login", "")
|
||||
repo = repo_data.get("name", "")
|
||||
|
||||
if owner != ALLOWED_OWNER:
|
||||
if config.ALLOWED_OWNERS and owner not in config.ALLOWED_OWNERS:
|
||||
return {"status": "skip", "reason": f"owner {owner} not allowed"}
|
||||
|
||||
if event == "issue_comment" and action == "created":
|
||||
|
||||
@ -2,7 +2,7 @@ import asyncio
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from config import GITEA_URL, GITEA_TOKEN, WORKSPACE_DIR, BOT_USERNAME
|
||||
from config import GITEA_URL, GITEA_TOKEN, WORKSPACE_DIR, BOT_USERNAME, BOT_GIT_NAME, BOT_GIT_EMAIL
|
||||
|
||||
log = logging.getLogger("gitea-bot")
|
||||
|
||||
@ -54,7 +54,7 @@ async def ensure_repo(owner: str, repo: str, issue_number: int) -> Path:
|
||||
raise RuntimeError(f"git clone failed: {err}")
|
||||
|
||||
# Configure git user for bot commits
|
||||
await _run(f'git config user.name "麻薯"', cwd=rp)
|
||||
await _run(f'git config user.email "ms@euphon.net"', cwd=rp)
|
||||
await _run(f'git config user.name "{BOT_GIT_NAME}"', cwd=rp)
|
||||
await _run(f'git config user.email "{BOT_GIT_EMAIL}"', cwd=rp)
|
||||
|
||||
return rp
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user