diff --git a/_webhook/deploy.php b/_webhook/deploy.php index 1c813b7..df2b532 100644 --- a/_webhook/deploy.php +++ b/_webhook/deploy.php @@ -10,7 +10,19 @@ if ($headerSecret !== $secret) { 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' => true, 'MESSAGE' => 'Deploy triggered', 'TIME' => date('c')]); +echo json_encode([ + 'OK' => $exitCode === 0, + 'MESSAGE' => $exitCode === 0 ? 'Deploy successful' : 'Deploy failed', + 'OUTPUT' => implode("\n", $output), + 'TIME' => date('c') +]);