Add webhook endpoint for auto-deployment

This commit is contained in:
oguz ozturk 2026-01-10 13:17:33 +03:00
parent 8d0b564738
commit c7f859ef35
1 changed files with 33 additions and 0 deletions

View File

@ -144,6 +144,39 @@ def get_domain(domain_id):
return jsonify(domain.to_dict()) 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__': if __name__ == '__main__':
with app.app_context(): with app.app_context():
db.create_all() db.create_all()