albert-m of DonInternet
1/30/2016 - 11:08 PM

PHP скрипт для обновления сайта на сервере через GIT

PHP скрипт для обновления сайта на сервере через GIT

<?php

// The commands
$commands = array(
  'git fetch --all',
  'git reset --hard origin/master',
  'drush updatedb -y',
  'drush features-revert-all -y',
  'drush cc all'
);

// Run the commands for output
$output = '';
foreach($commands AS $command){
  // Run it
  $tmp = shell_exec($command);
  // Output
  $output .= "<span style=\"color: #6BE234;\">\$</span> <span style=\"color: #729FCF;\">{$command}\n</span>";
  $output .= htmlentities(trim($tmp)) . "\n";
}

// Make it pretty for manual user access (and why not?)
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
  <meta charset="UTF-8">
  <title>GIT deployment script</title>
</head>
<body style="background-color: #000000; color: #FFFFFF; font-weight: bold; padding: 0 10px;">
<pre>
<?php echo $output; ?>
</pre>
</body>
</html>