false, 'ERROR' => 'unauthorized']); exit; } // Run git pull directly $repoPath = dirname(__DIR__); $output = []; $exitCode = 0; exec("cd " . escapeshellarg($repoPath) . " && git pull origin main 2>&1", $output, $exitCode); // Also write trigger file for backward compatibility $triggerFile = '/tmp/deploy-payfrit-api.trigger'; file_put_contents($triggerFile, date('Y-m-d H:i:s')); echo json_encode([ 'OK' => $exitCode === 0, 'MESSAGE' => $exitCode === 0 ? 'Deploy successful' : 'Deploy failed', 'OUTPUT' => implode("\n", $output), 'TIME' => date('c') ]);