Skip to content

Instantly share code, notes, and snippets.

@Golgarud
Last active February 19, 2018 15:24
Show Gist options
  • Save Golgarud/2fd5b04df2d621e92da16144d7dca010 to your computer and use it in GitHub Desktop.
Save Golgarud/2fd5b04df2d621e92da16144d7dca010 to your computer and use it in GitHub Desktop.
deployment.php
<?php
if ( !isset( $_GET["tkn"] ) || $_GET["tkn"] !== "MonSuperToken" )
{
header('HTTP/1.0 403 Forbidden');
echo "<h1>Nope :D</h1>";
die();
}
/**
* GIT DEPLOYMENT SCRIPT
*
* Used for automatically deploying websites via github or bitbucket, more deets here:
*
* https://gist.github.com/1809044
*/
// The commands
$commands = array(
'whoami',
'git checkout -f',
'git reset --hard',
'git pull',
'git status',
'git submodule init',
'git submodule sync',
'git submodule update',
'git submodule status',
);
// 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>
. ____ .
|/ \|
[| <span style="color: #FF0000;">&hearts; &hearts;</span> |] | Git Deployment Script v0.1 |
|___==___| / &copy; oodavid 2012 |
<?php echo $output; ?>
</pre>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment