Skip to content

Instantly share code, notes, and snippets.

@stmoerman
Created April 5, 2018 19:12
Show Gist options
  • Select an option

  • Save stmoerman/ca3447886cad92553aa4dd417541ca58 to your computer and use it in GitHub Desktop.

Select an option

Save stmoerman/ca3447886cad92553aa4dd417541ca58 to your computer and use it in GitHub Desktop.
<?php
// Set Variables
$LOCAL_ROOT = "/var/www/kreynation.com";
$LOCAL_REPO_NAME = "public_web";
$LOCAL_REPO = "{$LOCAL_ROOT}/{$LOCAL_REPO_NAME}";
$REMOTE_REPO = "[email protected]:devbowser/kreynation.com.git";
$BRANCH = "master";
if ( $_POST['payload'] ) {
// Only respond to POST requests from Github
shell_exec("cd {$LOCAL_REPO} && date >> git.log");
if( file_exists($LOCAL_REPO) ) {
// If there is already a repo, just run a git pull to grab the latest change $ shell_exec("cd {$LOCAL_REPO} && bin/grav clear-cache >> git.log");
shell_exec("cd {$LOCAL_REPO} && git pull >> git.log");
die("done " . mktime());
} else {
// If the repo does not exist, then clone it into the parent directory
shell_exec("cd {$LOCAL_ROOT} && git clone {$REMOTE_REPO} >> git.log");
die("done " . mktime());
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment