From 869b41b84df746288b60aea7aea5c58d26373371 Mon Sep 17 00:00:00 2001 From: "IGNY8 VPS (Salman)" Date: Mon, 10 Nov 2025 12:10:18 +0000 Subject: [PATCH] Simplify webhook to use direct git pull --- backend/igny8_core/modules/system/views.py | 44 ++++++++++++---------- scripts/auto-pull.sh | 3 ++ 2 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 scripts/auto-pull.sh diff --git a/backend/igny8_core/modules/system/views.py b/backend/igny8_core/modules/system/views.py index 38dda540..28274dc1 100644 --- a/backend/igny8_core/modules/system/views.py +++ b/backend/igny8_core/modules/system/views.py @@ -530,28 +530,32 @@ def gitea_webhook(request): logger.info(f"[Webhook] Processing push: {commit_count} commit(s) by {pusher} to {repo_full_name}") - # Pull latest code - run git pull directly in the mounted repo + # Pull latest code - trigger systemd service on host try: - import subprocess - logger.info(f"[Webhook] Pulling latest code...") - result = subprocess.run( - ['git', '-C', '/data/app/igny8', 'config', '--global', '--add', 'safe.directory', '/data/app/igny8'], - capture_output=True, - text=True, - timeout=5 - ) - result = subprocess.run( - ['git', '-C', '/data/app/igny8', 'pull', 'origin', 'main'], - capture_output=True, - text=True, - timeout=30 - ) - if result.returncode == 0: - logger.info(f"[Webhook] Git pull successful: {result.stdout}") - else: - logger.error(f"[Webhook] Git pull failed: {result.stderr}") + import socket + logger.info(f"[Webhook] Triggering git pull...") + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(5) + sock.connect(('127.0.0.1', 9999)) + sock.close() + logger.info(f"[Webhook] Git pull triggered successfully") except Exception as e: - logger.error(f"[Webhook] Git pull error: {e}") + logger.error(f"[Webhook] Failed to trigger git pull: {e}") + # Fallback: try direct git pull + try: + import subprocess + result = subprocess.run( + ['git', '-C', '/data/app/igny8', 'pull', 'origin', 'main'], + capture_output=True, + text=True, + timeout=30 + ) + if result.returncode == 0: + logger.info(f"[Webhook] Git pull successful (fallback)") + else: + logger.error(f"[Webhook] Git pull failed: {result.stderr}") + except Exception as e2: + logger.error(f"[Webhook] Fallback git pull also failed: {e2}") # Trigger deployment - restart containers deployment_success = False diff --git a/scripts/auto-pull.sh b/scripts/auto-pull.sh new file mode 100644 index 00000000..82e93db8 --- /dev/null +++ b/scripts/auto-pull.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cd /data/app/igny8 +git pull origin main