<?php
declare(strict_types=1);

// Run the deploy command
$output = [];
$return_var = 0;
exec("node deploy.js 2>&1", $output, $return_var);

$log = implode("\n", $output);
file_put_contents('bot.log', "[Deploy] " . date('Y-m-d H:i:s') . "\n" . $log . "\n\n", FILE_APPEND);

if ($return_var === 0) {
    header("Location: index.php?deploy_success=1");
} else {
    header("Location: index.php?deploy_error=1");
}
exit;
