Skip to content

Instantly share code, notes, and snippets.

@riodw
Last active May 8, 2023 08:54
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save riodw/71f6e2244534deae652962b32b7454e2 to your computer and use it in GitHub Desktop.
Save riodw/71f6e2244534deae652962b32b7454e2 to your computer and use it in GitHub Desktop.
Deploy to Production Server with git using PHP
<?php
/**
* GIT DEPLOYMENT SCRIPT
*
*/
// The commands
$commands = array(
'echo $PWD',
'whoami',
'git reset --hard HEAD',
'git pull',
'git status',
'git submodule sync',
'git submodule update',
'git submodule status',
);
// Run the commands for output
$output = '';
foreach($commands AS $command){
// Run it
$tmp = 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>
____________________________
| |
| Git Deployment Script v0.1 |
| github.com/riodw 2019 |
|____________________________|
<?php echo $output; ?>
</pre>
</body>
</html>
@cijagani
Copy link

though https://github.com/scriptburn/git-auto-deploy is not working properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment