32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
"""동기화 후 Gitea 최신 커밋 확인 + 배포 트리거"""
|
|
import paramiko, sys, time
|
|
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=20):
|
|
print(f'\n[{label}]')
|
|
_, o, e = client.exec_command(cmd, timeout=timeout)
|
|
print(o.read().decode('utf-8','replace').strip()[:500])
|
|
|
|
REPOS = ['guardia-itsm', 'guardia-manager', 'guardia-docs', 'zioinfo-web']
|
|
B64 = 'Authorization: Basic ' + __import__('base64').b64encode(b'zio:Zio@Admin2026!').decode()
|
|
|
|
for repo in REPOS:
|
|
run(f'Gitea {repo} 최신 커밋',
|
|
f'curl -sf "http://127.0.0.1:9003/api/v1/repos/zio/{repo}/commits?limit=1" '
|
|
f'--header "{B64}" 2>/dev/null | '
|
|
'python3 -c "import sys,json; d=json.load(sys.stdin); c=d[0]; print(c[\'sha\'][:8], c[\'commit\'][\'message\'][:50])" 2>/dev/null || echo FAIL')
|
|
|
|
# guardia-itsm 배포 트리거로 최신 코드 반영
|
|
run('guardia-itsm 배포 트리거',
|
|
'curl -sf -X POST http://localhost:9999 -H "Content-Type: application/json" '
|
|
'-H "X-Gitea-Event: push" '
|
|
'-d \'{"repository":{"name":"guardia-itsm"},"ref":"refs/heads/main"}\' 2>/dev/null')
|
|
|
|
time.sleep(10)
|
|
run('배포 결과', 'tail -8 /var/log/zioinfo/deploy.log 2>/dev/null')
|
|
|
|
client.close()
|