diff options
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | src/GitHubPagesDeploy/GitHubPagesDeploy.php | 14 |
2 files changed, 22 insertions, 7 deletions
@@ -1,7 +1,6 @@ # GitHub Pages Deploy -Deploys a number of repositories using the `gh-pages` branch, and keeps them -up to date. +Deploy and maintain a number of static web applications on GitHub pages. ## Installation @@ -31,3 +30,15 @@ $ php composer.phar create-project robloach/gh-pages-deploy ``` bash $ gh-pages-deploy/bin/gh-pages-deploy deploy ``` + +3. Set up a cron job to deploy every once in a while. +``` bash +$ gh-pages-deploy/bin/gh-pages-deploy deploy +``` + + +## License + +Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT license](http://creativecommons.org/licenses/MIT/) + +Copyright © Rob Loach (http://robloach.net) diff --git a/src/GitHubPagesDeploy/GitHubPagesDeploy.php b/src/GitHubPagesDeploy/GitHubPagesDeploy.php index 34c31d4..bcf2fde 100644 --- a/src/GitHubPagesDeploy/GitHubPagesDeploy.php +++ b/src/GitHubPagesDeploy/GitHubPagesDeploy.php @@ -33,6 +33,7 @@ class GitHubPagesDeploy $wrapper->streamOutput(); foreach ($this->repositories as $dir => $repo) { + // Build our git interface. $git = null; if (!is_dir($dir)) { $git = $wrapper->cloneRepository($repo, $dir); @@ -41,17 +42,20 @@ class GitHubPagesDeploy $git = new GitWorkingCopy($wrapper, $dir); } + // Fetch all the latest. + $git->fetch('--all'); + // Remove any local changes. $git->reset(array('hard' => true)); + // Clean up the repository. + $git->run(array('clean', array('d' => TRUE, 'f' => TRUE))); + // Ensure we are on the correct branch. - $git->checkout('gh-pages'); + $git->checkout('gh-pages', array('force' => TRUE)); - // Pull in any changes. + // Finally, pull in the changes. $git->pull(); - - // Ensure there aren't any local changes. - $git->reset(array('hard' => true)); } } |