599dcd62d9
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 15s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m9s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 49s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 29s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 10s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 16s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 3m54s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 25s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m42s
AI Code Review / AI Code Review (pull_request) Successful in 3m27s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m25s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m27s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 7m12s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 6s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 49m50s
统一 .gitea/workflows/ 和 scripts/ci/ 下的端口变量命名规范:
1. CI_PG_PORT → CI_LOCAL_PG_PORT
- 与 ci_env.sh 中的命名对齐,明确区分本地PG vs 共享PG
- 修改:ci-pipeline.yml 顶层env及2处DATABASE_URL引用
2. WEBHOOK_PORT → CHATOPS_WEBHOOK_PORT
- chatops内部变量名与外部环境变量名统一
- 减少命名混淆,全局搜索时能定位所有引用
- 修改:chatops/config.py + webhook_server.py
命名规范:{服务/场景}_{资源}_PORT
只改CI配置和脚本,不动业务代码。
56 lines
2.7 KiB
Python
Executable File
56 lines
2.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
ChatOps 配置管理 - 统一从环境变量读取配置,不硬编码任何敏感信息
|
|
|
|
环境变量:
|
|
GITEA_URL Gitea 地址 (默认 https://git.xiaoxiajianji.com)
|
|
GITEA_REPO 仓库路径 (默认 xiaoxia/xiaoxia-saas)
|
|
GITEA_TOKEN Gitea API Token (优先使用)
|
|
GITEA_USERNAME Gitea 用户名 (密码认证时)
|
|
GITEA_PASSWORD Gitea 密码 (密码认证时)
|
|
FEISHU_WEBHOOK_URL 飞书自定义机器人 webhook 地址
|
|
FEISHU_APP_ID 飞书应用 App ID (应用机器人模式,预留)
|
|
FEISHU_APP_SECRET 飞书应用 App Secret (应用机器人模式,预留)
|
|
CHATOPS_NOTIFY_BRANCHES 触发通知的分支,逗号分隔 (默认 main,develop)
|
|
CHATOPS_WEBHOOK_PORT webhook 服务监听端口 (默认 8090)
|
|
CHATOPS_WEBHOOK_SECRET Gitea webhook 密钥 (校验签名,可选)
|
|
"""
|
|
|
|
import os
|
|
|
|
# ── Gitea 配置 ────────────────────────────────────────
|
|
GITEA_URL = os.environ.get("GITEA_URL", "https://git.xiaoxiajianji.com").rstrip("/")
|
|
GITEA_REPO = os.environ.get("GITEA_REPO", "xiaoxia/xiaoxia-saas")
|
|
GITEA_TOKEN = os.environ.get("GITEA_TOKEN", "")
|
|
GITEA_USERNAME = os.environ.get("GITEA_USERNAME", "")
|
|
GITEA_PASSWORD = os.environ.get("GITEA_PASSWORD", "")
|
|
|
|
# ── 飞书配置 ──────────────────────────────────────────
|
|
FEISHU_WEBHOOK_URL = os.environ.get("FEISHU_WEBHOOK_URL", "")
|
|
FEISHU_APP_ID = os.environ.get("FEISHU_APP_ID", "")
|
|
FEISHU_APP_SECRET = os.environ.get("FEISHU_APP_SECRET", "")
|
|
|
|
# ── 通知配置 ──────────────────────────────────────────
|
|
NOTIFY_BRANCHES = [b.strip() for b in os.environ.get("CHATOPS_NOTIFY_BRANCHES", "main,develop").split(",") if b.strip()]
|
|
|
|
# ── Webhook 服务配置 ──────────────────────────────────
|
|
CHATOPS_WEBHOOK_PORT = int(os.environ.get("CHATOPS_WEBHOOK_PORT", "8090"))
|
|
WEBHOOK_SECRET = os.environ.get("CHATOPS_WEBHOOK_SECRET", "")
|
|
|
|
# ── 常量 ──────────────────────────────────────────────
|
|
PAGE_LIMIT = 50 # Gitea API 每页最大数量
|
|
|
|
|
|
def has_gitea_auth() -> bool:
|
|
"""检查是否配置了 Gitea 认证信息"""
|
|
if GITEA_TOKEN:
|
|
return True
|
|
if GITEA_USERNAME and GITEA_PASSWORD:
|
|
return True
|
|
return False
|
|
|
|
|
|
def has_feishu_webhook() -> bool:
|
|
"""检查是否配置了飞书 webhook"""
|
|
return bool(FEISHU_WEBHOOK_URL)
|