Created
May 18, 2014 03:12
-
-
Save saibotsivad/c9937d1e7a3a9c119cab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Based on some other things I've seen online. | |
1: Edit the vars | |
2: Put on server somewhere accessible, e.g. your site folder as github.php | |
3: chmod +x github.php | |
4: Repo settings, add webhook to that url | |
*/ | |
$LOCAL_ROOT = "/home/username/site.com"; | |
$LOCAL_REPO_NAME = "content"; | |
$LOCAL_REPO = "{$LOCAL_ROOT}/{$LOCAL_REPO_NAME}"; | |
$REMOTE_REPO = "https://github.com/username/repo.git"; | |
$BRANCH = "master"; | |
if ( $_POST['payload'] ) { | |
if( file_exists($LOCAL_REPO) ) { | |
shell_exec("cd {$LOCAL_REPO} && git pull"); | |
die("done " . mktime()); | |
} else { | |
shell_exec("cd {$LOCAL_ROOT} && git clone {$REMOTE_REPO} {$LOCAL_REPO_NAME}"); | |
die("done " . mktime()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment