Skip to content

Instantly share code, notes, and snippets.

@abeyuya
Last active June 14, 2016 12:36
Show Gist options
  • Save abeyuya/5071638 to your computer and use it in GitHub Desktop.
Save abeyuya/5071638 to your computer and use it in GitHub Desktop.
bitbucketからの自動デプロイ ref: http://qiita.com/abeyuya/items/773c26384297efe1f9a1
<?php
if($_SERVER["REQUEST_METHOD"] != "POST"){
// GETによるアクセス
}else{
// POSTによるアクセス
$cmd = '. /var/www/html/update.sh';
$retstr = system($cmd, $res);
$fp = fopen("deploy.log", "a");
fwrite($fp, date('c')."\n");
if ($retstr === FALSE || 0 !== $res) {
fwrite($fp, "cmd false\n");
} else {
fwrite($fp, $res."\n");
}
fclose($fp);
}
?>
#!/bin/sh
cd /var/www/html/[rep-name]
/usr/bin/git --git-dir=/var/www/html/[rep-name]/.git pull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment