Simplify webhook to use direct git pull
This commit is contained in:
@@ -530,16 +530,20 @@ def gitea_webhook(request):
|
|||||||
|
|
||||||
logger.info(f"[Webhook] Processing push: {commit_count} commit(s) by {pusher} to {repo_full_name}")
|
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 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] Failed to trigger git pull: {e}")
|
||||||
|
# Fallback: try direct git pull
|
||||||
try:
|
try:
|
||||||
import subprocess
|
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(
|
result = subprocess.run(
|
||||||
['git', '-C', '/data/app/igny8', 'pull', 'origin', 'main'],
|
['git', '-C', '/data/app/igny8', 'pull', 'origin', 'main'],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
@@ -547,11 +551,11 @@ def gitea_webhook(request):
|
|||||||
timeout=30
|
timeout=30
|
||||||
)
|
)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
logger.info(f"[Webhook] Git pull successful: {result.stdout}")
|
logger.info(f"[Webhook] Git pull successful (fallback)")
|
||||||
else:
|
else:
|
||||||
logger.error(f"[Webhook] Git pull failed: {result.stderr}")
|
logger.error(f"[Webhook] Git pull failed: {result.stderr}")
|
||||||
except Exception as e:
|
except Exception as e2:
|
||||||
logger.error(f"[Webhook] Git pull error: {e}")
|
logger.error(f"[Webhook] Fallback git pull also failed: {e2}")
|
||||||
|
|
||||||
# Trigger deployment - restart containers
|
# Trigger deployment - restart containers
|
||||||
deployment_success = False
|
deployment_success = False
|
||||||
|
|||||||
3
scripts/auto-pull.sh
Normal file
3
scripts/auto-pull.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd /data/app/igny8
|
||||||
|
git pull origin main
|
||||||
Reference in New Issue
Block a user