// If this script is being called from the command line, // go ahead and try to deploy using the command line // arguments. if ("cli" == php_sapi_name()) { set_include_path(get_include_path() . PATH_SEPARATOR . "lib/phpseclib0"); $deployer = new Deployer(); if (count($argv) < 4) { echo "Usage: php Deployer.php APP environment [deployed by]\n"; exit; } if (!array_key_exists($argv[1], $application_configs)) { echo "Invalid application.\n"; exit; } $application = $application_configs[$argv[1]]; $deployer->deploy($application, $argv[2], $argv[3]); } class Deployer { var $dao; public function __construct($dao = null) { if (null == $dao) { $this->dao = new DeploymentDAO(); } else { $this->dao = $dao; } } public function deploy($application, $environment = 'production', $deployed_by = null, $comment = null) { $deployment = new Deployment();
<?php // Require the deployer class require_once 'php-deployer.php'; $config = array('remote' => 'https://github.com/Swiper-CCCVI/php-github-deploy.git', 'target' => '/var/www/default', 'branch' => 'master', 'temp' => '/tmp/deploy', 'secret' => 'yoursecretaccesstoken', 'exclude' => '.exclude'); // Initialize the deployer $deployer = new Deployer($config); // Deploy the deployer $deployer->deploy(); // Log the deployer output $deployer->log_output('/var/log/deploy.log'); // Echo the deployer output $deployer->echo_output();
if (false === $this->deploy_new_build($new_build_path)) { return $this->finish(false, $new_build_path); } return $this->finish(true, $new_build_path); } } $app->post('/deploy/{service}', function (Application $app, Request $request, $service) { if (isset($app['config'][$service])) { $config = $app['config'][$service]; $secret = $request->get("secret"); if ($secret != $config['secret']) { return new Response("Forbidden", 403, array('Content-Type' => 'text/plain')); } $deployer = new Deployer($service, $config); $stream = function () use($deployer, $request) { $deployer->deploy($request); }; return $app->stream($stream, 200, array('Content-Type' => 'text/plain')); } return "ERROR: missing service: " . $service; }); $app->post('/rollback/{service}', function (Application $app, Request $request, $service) { if (isset($app['config'][$service])) { $config = $app['config'][$service]; $secret = $request->get("secret"); if ($secret != $config['secret']) { return new Response("Forbidden", 403, array('Content-Type' => 'text/plain')); } $deployer = new Deployer($service, $config); $deployer->recursive_unlink($config['current_path']); if (!@rename($config['old_path'], $config['current_path'])) {
<?php require_once "config.php"; require_once DEPLOYMENT_SCRIPTS . "/Applications.php"; require_once "Deployer.php"; require_once "DeploymentDAO.php"; // This page is only accessible via POST. if (!strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && empty($_POST)) { header("Location: index.php"); exit; } $deployer = new Deployer(); $deploy_to = preg_replace("/push to /", "", $_POST['push_environment']); $application = $application_configs[$_POST['app']]; $deployment = $deployer->deploy($application, $deploy_to, $_SERVER['PHP_AUTH_USER'], $_POST['comment']); if (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { echo json_encode(array("result" => "success")); } else { header("Location: index.php"); }