Add webhook endpoint for auto-deployment
This commit is contained in:
parent
8d0b564738
commit
c7f859ef35
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue