- 新增 _get_gitea_config.py 从 YAML 读取 URL/repo/token
- _common.sh 改为通过 eval python 脚本加载配置
- GITEA_CICD_SETUP.md / DEV_AGENT.md / QE_AGENT.md 更新文档
- CI 工作流改用 ${{ gitea.server_url }} / ${{ gitea.repository }}
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+27
-11
@@ -21,19 +21,35 @@ import sys
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
|
||||
GITEA_URL = os.environ.get("GITEA_URL", "https://git.zywl.me")
|
||||
GITEA_REPO = os.environ.get("GITEA_REPO", "zeekrAI/document_analyzer")
|
||||
GITEA_TOKEN = os.environ.get("GITEA_API_TOKEN", "")
|
||||
DEV_AGENT_ID = os.environ.get("DEV_AGENT_ID", "da-01")
|
||||
QE_AGENT_ID = os.environ.get("QE_AGENT_ID", "")
|
||||
def _load_gitea_config():
|
||||
"""Load Gitea URL, repo, and token from ~/.gitea/config.yaml or env vars."""
|
||||
config_path = os.path.expanduser("~/.gitea/config.yaml")
|
||||
if os.path.exists(config_path):
|
||||
import yaml # requires pyyaml
|
||||
with open(config_path) as f:
|
||||
config = yaml.safe_load(f) or {}
|
||||
user = os.environ.get("GITEA_USER")
|
||||
if not user:
|
||||
print("Error: GITEA_USER is not set (required for ~/.gitea/config.yaml).",
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
profile = config.get(user)
|
||||
if not profile:
|
||||
print(f"Error: user '{user}' not found in {config_path}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
return (profile.get("url", ""), profile.get("repo", ""),
|
||||
profile.get("token", ""))
|
||||
# Fallback: plain env vars (for CI / backwards compat)
|
||||
return (os.environ.get("GITEA_URL", ""),
|
||||
os.environ.get("GITEA_REPO", ""),
|
||||
os.environ.get("GITEA_API_TOKEN", ""))
|
||||
|
||||
|
||||
GITEA_URL, GITEA_REPO, GITEA_TOKEN = _load_gitea_config()
|
||||
GITEA_USER = os.environ.get("GITEA_USER", "")
|
||||
|
||||
# Signature appended to all comments / PR bodies
|
||||
if QE_AGENT_ID:
|
||||
AGENT_ID = QE_AGENT_ID
|
||||
AGENT_SIG = f"\n\n---\n[qe-agent: {QE_AGENT_ID}]"
|
||||
else:
|
||||
AGENT_ID = DEV_AGENT_ID
|
||||
AGENT_SIG = f"\n\n---\n[{DEV_AGENT_ID}]"
|
||||
AGENT_SIG = f"\n\n---\n[{GITEA_USER}]" if GITEA_USER else ""
|
||||
|
||||
BASE = f"{GITEA_URL}/api/v1/repos/{GITEA_REPO}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user