30825912f4
[TSM.ID].[11031972] PXE : Platform X Ecosystem I [142 Module - REAL LIVE -] / 3Z: Zero Error Check (142 Modules) (push) Waiting to run
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
from flask import Flask, request, jsonify
|
|
import subprocess
|
|
import os
|
|
|
|
app = Flask(__name__)
|
|
|
|
# Secret token for Gitea Webhook validation
|
|
WEBHOOK_SECRET = os.environ.get("PHANTOM_SECRET", "super-secret-phantom-token")
|
|
|
|
@app.route('/phantom-webhook', methods=['POST'])
|
|
def handle_webhook():
|
|
payload = request.json
|
|
|
|
# Simple check for push events to main branch
|
|
if payload and 'ref' in payload:
|
|
if payload['ref'] == 'refs/heads/main':
|
|
print("[Phantom V5.2] Detected push to main branch! Initiating CI/CD...")
|
|
|
|
# Simulated deployment action
|
|
try:
|
|
# In production, this would trigger an Ansible playbook or shell script
|
|
# subprocess.run(["ansible-playbook", "-i", "inventory", "deploy.yml"], check=True)
|
|
print("[Phantom V5.2] CI/CD Pipeline executed successfully across XCU nodes.")
|
|
return jsonify({"status": "success", "message": "Deployed to XCU cluster"}), 200
|
|
except Exception as e:
|
|
print(f"[Phantom V5.2] CI/CD Pipeline failed: {e}")
|
|
return jsonify({"status": "error", "message": str(e)}), 500
|
|
|
|
return jsonify({"status": "ignored", "message": "Not a main branch push"}), 200
|
|
|
|
if __name__ == '__main__':
|
|
# Listen on port 9099 as per architecture
|
|
app.run(host='0.0.0.0', port=9099)
|