forked from BLC/AyposWeb
CI/CD
This commit is contained in:
12
.env.example
12
.env.example
@@ -1,12 +0,0 @@
|
||||
# API Configuration
|
||||
VITE_API_URL=http://141.196.166.241:8003
|
||||
|
||||
# Vercel Deployment Configuration
|
||||
NEXT_PUBLIC_ALLOWED_HOSTS=141.196.166.241
|
||||
NEXT_PUBLIC_VERCEL_URL=${VERCEL_URL}
|
||||
NODE_ENV=production
|
||||
|
||||
# CORS Configuration
|
||||
CORS_ORIGIN=*
|
||||
|
||||
# Add other environment variables as needed
|
||||
24
deploy.sh
Normal file
24
deploy.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
APP_DIR="/home/ubuntu/AyposWeb"
|
||||
|
||||
# Navigate to your app directory
|
||||
cd "$APP_DIR" || { echo "Failed to cd to $APP_DIR"; exit 1; }
|
||||
|
||||
# Pull latest changes from Gitea
|
||||
echo "Pulling latest code..."
|
||||
git pull origin main || { echo "Git pull failed"; exit 1; }
|
||||
|
||||
# Build your app (change this to your build command)
|
||||
# For example, npm build:
|
||||
echo "Installing dependencies..."
|
||||
npm install || { echo "npm install failed"; exit 1; }
|
||||
|
||||
echo "Building app..."
|
||||
npm run build || { echo "npm build failed"; exit 1; }
|
||||
|
||||
# Restart your app (change this to your app's restart command)
|
||||
# For example, systemctl restart myapp.service:
|
||||
systemctl reload nginx || { echo "Failed to reload nginx"; exit 1; }
|
||||
|
||||
echo "Deployment complete"
|
||||
607
package-lock.json
generated
607
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -5,8 +5,10 @@ import {
|
||||
CategoryScale,
|
||||
LinearScale,
|
||||
BarElement,
|
||||
BarController,
|
||||
PointElement,
|
||||
LineElement,
|
||||
LineController,
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend,
|
||||
@@ -18,8 +20,10 @@ ChartJS.register(
|
||||
CategoryScale,
|
||||
LinearScale,
|
||||
BarElement,
|
||||
BarController,
|
||||
PointElement,
|
||||
LineElement,
|
||||
LineController,
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend
|
||||
@@ -225,4 +229,4 @@ const ResourceDistributionChart: React.FC<ResourceDistributionChartProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default ResourceDistributionChart;
|
||||
export default ResourceDistributionChart;
|
||||
|
||||
@@ -898,10 +898,10 @@ const Home = () => {
|
||||
migration_advices: {
|
||||
migration_method: migrationMethod === 'mathematical' ? 'migration_advices_la' : 'migration_advices_llm',
|
||||
migration_weights: {
|
||||
power: weights.energy.toString(),
|
||||
balance: weights.balance.toString(),
|
||||
overload: weights.overload.toString(),
|
||||
allocation: weights.allocation.toString()
|
||||
power: (weights.energy / 100).toString(),
|
||||
balance: (weights.balance / 100).toString(),
|
||||
overload: (weights.overload / 100).toString(),
|
||||
allocation: (weights.allocation / 100).toString()
|
||||
}
|
||||
},
|
||||
block_list: blockList
|
||||
|
||||
50
webhook_listener.py
Normal file
50
webhook_listener.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from flask import Flask, request, abort
|
||||
import hmac
|
||||
import hashlib
|
||||
import subprocess
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# Optional: Add a secret token to verify webhook source
|
||||
WEBHOOK_SECRET = b'Aypos-web-hook'
|
||||
|
||||
def verify_signature(signature_header, body):
|
||||
# Implement if you want to verify the webhook signature from Gitea
|
||||
if not signature_header:
|
||||
return False
|
||||
|
||||
try:
|
||||
sig_prefix, sig_hash = signature_header.split("=")
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
if sig_prefix != "sha256":
|
||||
return False
|
||||
|
||||
# Calculate HMAC digest and compare securely
|
||||
digest = hmac.new(WEBHOOK_SECRET, body, hashlib.sha256).hexdigest()
|
||||
return hmac.compare_digest(digest, sig_hash)
|
||||
|
||||
|
||||
@app.route("/webhook", methods=["POST"])
|
||||
def webhook():
|
||||
signature_header = request.headers.get("X-Gitea-Signature")
|
||||
body = request.data
|
||||
|
||||
if not verify_signature(signature_header, body):
|
||||
return "Invalid or missing signature", 403
|
||||
|
||||
event = request.headers.get("X-Gitea-Event")
|
||||
if event != "push":
|
||||
return "Unsupported event type", 400
|
||||
|
||||
try:
|
||||
output = subprocess.check_output(["./deploy.sh"], stderr=subprocess.STDOUT)
|
||||
print(output.decode())
|
||||
return "Deployment triggered", 200
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Deployment error:", e.output.decode())
|
||||
return "Deployment failed", 500
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5000)
|
||||
Reference in New Issue
Block a user