diff --git a/deploy.php b/deploy.php new file mode 100644 index 0000000..20cd84d --- /dev/null +++ b/deploy.php @@ -0,0 +1,128 @@ +&1', + 'cd ' . escapeshellarg(REPO_PATH) . ' && ' . GIT_BIN . ' checkout ' . escapeshellarg(ALLOWED_BRANCH) . ' 2>&1', + 'cd ' . escapeshellarg(REPO_PATH) . ' && ' . GIT_BIN . ' pull origin ' . escapeshellarg(ALLOWED_BRANCH) . ' 2>&1', +]; + +$outputAll = []; +$returnCode = 0; + +foreach ($commands as $cmd) { + $output = []; + $cmdReturn = 0; + exec($cmd, $output, $cmdReturn); + + $outputAll[] = '$ ' . $cmd; + $outputAll[] = implode("\n", $output); + $outputAll[] = 'exit_code=' . $cmdReturn; + + if ($cmdReturn !== 0) { + $returnCode = $cmdReturn; + break; + } +} + +log_line("PROJECT_KEY=" . PROJECT_KEY . "\n" . implode("\n", $outputAll) . "\n---"); + +if ($returnCode !== 0) { + respond(500, 'Deploy failed. Revisa deploy.log'); +} + +respond(200, 'Deploy OK'); \ No newline at end of file diff --git a/index.html b/index.html index ad3ea74..9eb540e 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,6 @@