Skip to content

Commit fa66fd6

Browse files
committed
refactor(design-announce): externalize runtime configuration
- Move QQ_ENDPOINT and QQ_GROUP_ID to environment variables - Update workflow to inject required config via secrets
1 parent 541ecf7 commit fa66fd6

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

.github/workflows/design-review.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
env:
2929
DIFF_BASE: ${{ github.event.before }}
3030
OPENAI_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
31+
QQ_ENDPOINT: ${{ secrets.QQ_ENDPOINT }}
32+
QQ_GROUP_ID: ${{ secrets.QQ_GROUP_ID }}
3133
run: |
3234
if [ -n "${DIFF_BASE}" ]; then
3335
python scripts/design_diff_announce.py --base "${DIFF_BASE}"

scripts/design_diff_announce.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
# Hard-coded interface so the workflow stays deterministic.
2222
OPENAI_ENDPOINT = "https://api.deepseek.com/v1/chat/completions"
2323
OPENAI_MODEL = "deepseek-chat"
24-
QQ_ENDPOINT = "http://119.23.57.80:53000/_send_group_notice"
25-
QQ_GROUP_ID = 457054386
2624
QQ_MAX_RETRIES = 5
2725
PROMPT_TEMPLATE_PATH = Path(__file__).with_name("design_announce_prompt.txt")
2826

@@ -419,18 +417,18 @@ def _http_post(url: str, payload: bytes, headers: dict[str, str]) -> str:
419417
raise RuntimeError(f"HTTP request failed: {exc}") from exc
420418

421419

422-
def send_to_qq(message: str, path: Path, dry_run: bool) -> None:
420+
def send_to_qq(message: str, path: Path, dry_run: bool, qq_endpoint: str, qq_group_id: int) -> None:
423421
if dry_run:
424422
logging.info("Dry run QQ dispatch for %s:\n%s", path, message)
425423
return
426-
payload = json.dumps({"group_id": QQ_GROUP_ID, "content": message}).encode("utf-8")
424+
payload = json.dumps({"group_id": qq_group_id, "content": message}).encode("utf-8")
427425
headers = {
428426
"Content-Type": "application/json",
429427
"Authorization": "Bearer rmstoken",
430428
}
431429
for attempt in range(1, QQ_MAX_RETRIES + 1):
432430
try:
433-
_http_post(QQ_ENDPOINT, payload, headers)
431+
_http_post(qq_endpoint, payload, headers)
434432
logging.info("QQ announcement sent for %s on attempt %d", path, attempt)
435433
return
436434
except RuntimeError as exc:
@@ -468,6 +466,19 @@ def main() -> int:
468466
if not api_key:
469467
logging.error("API key is missing; use --key or set OPENAI_API_KEY")
470468
return 1
469+
qq_endpoint = os.getenv("QQ_ENDPOINT")
470+
if not qq_endpoint:
471+
logging.error("QQ endpoint is missing; set QQ_ENDPOINT environment variable")
472+
return 1
473+
qq_group_id_str = os.getenv("QQ_GROUP_ID")
474+
if not qq_group_id_str:
475+
logging.error("QQ group ID is missing; set QQ_GROUP_ID environment variable")
476+
return 1
477+
try:
478+
qq_group_id = int(qq_group_id_str)
479+
except ValueError:
480+
logging.error("QQ_GROUP_ID must be an integer, got: %s", qq_group_id_str)
481+
return 1
471482
range_spec, base_commit = determine_range(args.base)
472483
repo_root = get_repo_root()
473484
changed_files = gather_changed_files(range_spec)
@@ -486,7 +497,7 @@ def main() -> int:
486497
return 0
487498
# Generate single combined announcement for all files.
488499
announcement = summarize_all_files(files_with_chunks, args.dry_run, api_key)
489-
send_to_qq(announcement, Path("combined"), args.dry_run)
500+
send_to_qq(announcement, Path("combined"), args.dry_run, qq_endpoint, qq_group_id)
490501
logging.info("Processed %d markdown files in single announcement.", len(files_with_chunks))
491502
return 0
492503

0 commit comments

Comments
 (0)