From c7f859ef35335c0dec080fa6f1c89b32932239f4 Mon Sep 17 00:00:00 2001 From: oguz ozturk Date: Sat, 10 Jan 2026 13:17:33 +0300 Subject: [PATCH] Add webhook endpoint for auto-deployment --- backend/app/main.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/backend/app/main.py b/backend/app/main.py index 9466fc3..4a4c453 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -144,6 +144,39 @@ def get_domain(domain_id): return jsonify(domain.to_dict()) +@app.route('/webhook/deploy', methods=['POST']) +def webhook_deploy(): + """Gitea webhook for auto-deployment""" + import subprocess + import os + + # Verify webhook (optional: add secret validation) + data = request.json + + # Log webhook event + print(f"📥 Webhook received: {data.get('repository', {}).get('name', 'unknown')}") + + # Trigger deployment script + try: + result = subprocess.run( + ['/opt/hosting-platform/deploy.sh'], + capture_output=True, + text=True, + timeout=300 + ) + + return jsonify({ + "status": "success", + "message": "Deployment triggered", + "output": result.stdout + }) + except Exception as e: + return jsonify({ + "status": "error", + "message": str(e) + }), 500 + + if __name__ == '__main__': with app.app_context(): db.create_all()