Skip to content

Instantly share code, notes, and snippets.

@suvozy
Last active August 29, 2015 13:56
Show Gist options
  • Save suvozy/9342980 to your computer and use it in GitHub Desktop.
Save suvozy/9342980 to your computer and use it in GitHub Desktop.
Git Deploy
sudo -i

#Build webapp key

sudo -Hu webapp ssh-keygen -t rsa # choose "no passphrase"

or

sudo -Hu webapp ssh-keygen -t rsa -C "server-webapp@rime.co"

##Clone

cat /home/webapp/.ssh/id_rsa.pub
sudo -Hu webapp git clone git@github.com:suvozit/log-pixel.git /var/www/html

###OR

su -l webapp
git clone git@github.com:suvozit/log-pixel.git /var/app/current

#Build Server key ##Generate https://help.github.com/articles/generating-ssh-keys

##Apply

cat id_rsa.pub

https://github.com/settings/ssh

##Hanlde Error https://help.github.com/articles/error-permission-denied-publickey

#Clean html folder

cd /var/www/html
rm -rf .* *

#Clone Source

git clone git@github.com:suvozit/log-pixel.git /var/www/html

git reset --hard HEAD
<?php
/**
* GIT DEPLOYMENT SCRIPT
*
* Used for automatically deploying websites via github or bitbucket, more deets here:
*
* https://gist.github.com/1809044
*/
// The commands
$commands = array(
'echo $PWD',
'whoami',
//'git reset --hard',
'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 = 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="font-weight: bold; padding: 0 10px;">
<pre>
. ____ . ____________________________
|/ \| | |
[| <span style="color: #FF0000;">O O</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