Skip to content

Instantly share code, notes, and snippets.

@p4ul
Created August 14, 2013 06:50
Show Gist options
  • Save p4ul/6228590 to your computer and use it in GitHub Desktop.
Save p4ul/6228590 to your computer and use it in GitHub Desktop.
quick in dirty self updater for use with github webhooks
<pre>
<?php
// ---------------------- CONFIG DETAILS ----------------------
//branch in git
$BRANCH = 'master';
// --------- You should not need to edit below here ------------
$current_sha1 = `git rev-parse $BRANCH`;
$status_of_branch = `git ls-remote origin -h refs/heads/$BRANCH`;
if( strpos(trim($status_of_branch), trim($current_sha1)) !== false) {
echo "no changes on branch $BRANCH \n";
return;
}
echo "Pulling\n";
$pull = `git pull`;
echo ".\n";
echo "Clearing Cache\n";
$cache = `drush cc all`;
echo ".\n";
echo "Finished \n";
echo "pull:". $pull , "\n";
echo "cache:".$cache , "\n";
$sha1 = `git rev-parse $BRANCH`;
$changelog = `git log $BRANCH -1 --format="%s"`;
echo "sha1:". $sha1 , "\n";
echo "changelog:".$changelog , "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment