55 lines
2.3 KiB
Python
55 lines
2.3 KiB
Python
"""zioinfo-web 서버 커밋(스크린샷 등) → Gitea push + 나머지 uncommitted 처리"""
|
|
import paramiko, sys, time
|
|
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('101.79.17.164', username='root', password='1q2w3e!Q', timeout=15)
|
|
sftp = c.open_sftp()
|
|
|
|
def run(label, cmd, timeout=60):
|
|
print(f'\n[{label}]')
|
|
_, o, _ = c.exec_command(cmd, timeout=timeout)
|
|
out = o.read().decode('utf-8','replace').strip()
|
|
if out: print(out[:500])
|
|
return out
|
|
|
|
GITEA = 'http://zio:Zio%40Admin2026%21@127.0.0.1:9003/zio/zioinfo-web.git'
|
|
|
|
# 1. 서버 남은 uncommitted 처리
|
|
run('uncommitted 상태',
|
|
'git -C /opt/zioinfo/src status --short 2>/dev/null | '
|
|
"grep -v 'static/assets/' | grep -v '.pyc'")
|
|
|
|
run('남은 파일 추가 commit',
|
|
'''cd /opt/zioinfo/src
|
|
git config user.email "ci@zioinfo.co.kr" 2>/dev/null
|
|
git config user.name "CI Bot" 2>/dev/null
|
|
# 모든 static 파일 추가 (빌드 산출물 제외)
|
|
git add backend/src/main/resources/static/zioinfo-building.png 2>/dev/null
|
|
git add backend/src/main/resources/static/zioinfo-logo*.png 2>/dev/null
|
|
git add backend/src/main/resources/static/*.png 2>/dev/null
|
|
git add backend/src/main/resources/static/index.html 2>/dev/null
|
|
git diff --cached --stat 2>/dev/null | head -10
|
|
git commit -m "chore: add static assets (logos, building photo)" 2>/dev/null || echo "nothing to commit"
|
|
''')
|
|
|
|
# 2. 서버 커밋들을 Gitea에 push
|
|
run('서버 현재 커밋 로그',
|
|
'git -C /opt/zioinfo/src log --oneline -3 2>/dev/null')
|
|
|
|
run('Gitea push (서버 → Gitea)',
|
|
f'git -C /opt/zioinfo/src remote set-url origin "{GITEA}" && '
|
|
'git -C /opt/zioinfo/src push origin main --force 2>&1 | tail -5')
|
|
|
|
# 3. 최신 Gitea 커밋 확인
|
|
run('Gitea 최신 커밋 확인',
|
|
'curl -sf "http://127.0.0.1:9003/api/v1/repos/zio/zioinfo-web/commits?limit=2" '
|
|
'-H "Authorization: Basic emhvOlppb0BBZG1pbjIwMjYh" 2>/dev/null | '
|
|
'python3 -c "import sys,json; [print(c[\'sha\'][:8], c[\'commit\'][\'message\'][:50]) for c in json.load(sys.stdin)]" 2>/dev/null')
|
|
|
|
# 4. /var/www/zioinfo 최신 상태 확인
|
|
run('www/zioinfo 날짜', 'stat /var/www/zioinfo/index.html 2>/dev/null | grep Modify')
|
|
|
|
sftp.close()
|
|
c.close()
|
|
print('\n=== 완료 ===')
|