"""Phase 3: Gitea webhook 연결 + 각 독립 repo remote 설정""" import paramiko, sys, subprocess, os sys.stdout.reconfigure(encoding='utf-8', errors='replace') client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect('101.79.17.164', username='root', password='1q2w3e!Q', timeout=15) def run(label, cmd, timeout=30): print(f' [{label}]') _, o, e = client.exec_command(cmd, timeout=timeout) out = o.read().decode('utf-8', errors='replace').strip() if out: print(f' {out[:200]}') return out REPOS_WEBHOOK = ["zioinfo-web", "guardia-itsm", "guardia-manager", "guardia-messenger"] print('[Gitea webhook 등록]') for repo in REPOS_WEBHOOK: run(f'webhook {repo}', f""" # 기존 webhook 삭제 HOOKS=$(curl -sf 'http://127.0.0.1:9003/api/v1/repos/zio/{repo}/hooks' \ -u 'zio:Zio@Admin2026!' 2>/dev/null | \ python3 -c "import sys,json; [print(h['id']) for h in json.load(sys.stdin)]" 2>/dev/null) for HID in $HOOKS; do curl -sf -X DELETE "http://127.0.0.1:9003/api/v1/repos/zio/{repo}/hooks/$HID" \ -u 'zio:Zio@Admin2026!' 2>/dev/null done # 신규 webhook 등록 R=$(curl -sf -X POST 'http://127.0.0.1:9003/api/v1/repos/zio/{repo}/hooks' \ -u 'zio:Zio@Admin2026!' \ -H 'Content-Type: application/json' \ -d '{{"type":"gitea","config":{{"url":"http://localhost:9999","content_type":"json","secret":"zioinfo-deploy-2026"}},"events":["push"],"active":true}}' 2>/dev/null) echo "$R" | python3 -c "import sys,json; d=json.load(sys.stdin); print('OK id:', d.get('id','error'))" 2>/dev/null """) client.close() # 각 독립 repo에 Gitea remote 설정 (로컬) print('\n[로컬 독립 repo Gitea remote 설정]') REPOS = { "zioinfo-web": "zio/zioinfo-web", "guardia-itsm": "zio/guardia-itsm", "guardia-manager": "zio/guardia-manager", "guardia-messenger": "zio/guardia-messenger", "guardia-docs": "zio/guardia-docs", } for local, gitea in REPOS.items(): path = f"C:/GUARDiA/repos/{local}" url_https = f"https://zio:Zio%40Admin2026%21@zioinfo.co.kr:3000/{gitea}.git" url_http = f"http://zio:Zio%40Admin2026%21@101.79.17.164:3000/{gitea}.git" subprocess.run(['git', '-C', path, 'remote', 'remove', 'origin'], capture_output=True) subprocess.run(['git', '-C', path, 'remote', 'add', 'origin', url_http], capture_output=True) r = subprocess.run(['git', '-C', path, 'remote', '-v'], capture_output=True, text=True) print(f' {local}: {r.stdout.splitlines()[0] if r.stdout else "OK"}') # 모노레포 remote 최종 확인 print('\n[모노레포 remote 최종 확인]') r = subprocess.run(['git', '-C', 'C:/GUARDiA', 'remote', '-v'], capture_output=True, text=True) print(r.stdout) print('=== Phase 3 완료 ===')