summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Loach <robloach@gmail.com>2013-12-14 16:41:10 -0500
committerRob Loach <robloach@gmail.com>2013-12-14 16:41:10 -0500
commit2596307917045df71d8922d7bc46bad00f5ec694 (patch)
tree05ba8d84756332a1eecfe0896472cd5e43f7ca5c
parentd0fc289e7839727ea42abfa6244713a4a94991dc (diff)
downloadgit-deploy-2596307917045df71d8922d7bc46bad00f5ec694.zip
git-deploy-2596307917045df71d8922d7bc46bad00f5ec694.tar.gz
git-deploy-2596307917045df71d8922d7bc46bad00f5ec694.tar.bz2
Initial commit
-rw-r--r--.editorconfig10
-rw-r--r--.gitignore4
-rw-r--r--LICENSE.md25
-rw-r--r--README.md51
-rwxr-xr-xbin/gh-pages-deploy4
-rw-r--r--bin/gh-pages-deploy.php43
-rw-r--r--box.json25
-rw-r--r--composer.json28
-rw-r--r--src/GitHubPagesDeploy/Console/Application.php24
-rw-r--r--src/GitHubPagesDeploy/Console/Command/DeployCommand.php33
-rw-r--r--src/GitHubPagesDeploy/GitHubPagesDeploy.php53
-rw-r--r--src/bootstrap.php15
12 files changed, 312 insertions, 3 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..153cf3e
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,10 @@
+; top-most EditorConfig file
+root = true
+
+; Unix-style newlines
+[*]
+end_of_line = LF
+
+[*.php]
+indent_style = space
+indent_size = 4
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f65ea0f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+build
+composer.lock
+vendor
+composer.phar
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..13c74b4
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,25 @@
+LICENSE
+=======
+
+GitHub Pages Manager is released under the MIT License:
+
+> Copyright (C) 2013 [Rob Loach](http://robloach.net)
+>
+> Permission is hereby granted, free of charge, to any person obtaining
+> a copy of this software and associated documentation files (the
+> "Software"), to deal in the Software without restriction, including
+> without limitation the rights to use, copy, modify, merge, publish,
+> distribute, sublicense, and/or sell copies of the Software, and to
+> permit persons to whom the Software is furnished to do so, subject to
+> the following conditions:
+>
+> The above copyright notice and this permission notice shall be
+> included in all copies or substantial portions of the Software.
+>
+> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index e83e593..7085b27 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,49 @@
-gh-pages-deploy
-===============
+# GitHub Pages Deploy
-Deploy a number of repositories using the gh-pages branch.
+[![Build Status](https://travis-ci.org/RobLoach/GitHubPagesDeploy.png)](https://travis-ci.org/RobLoach/GitHubPagesDeploy)
+[![Coverage Status](https://coveralls.io/repos/RobLoach/GitHubPagesDeploy/badge.png?branch=master)](https://coveralls.io/r/RobLoach/GitHubPagesDeploy?branch=master)
+[![Total Downloads](https://poser.pugx.org/RobLoach/GitHubPagesDeploy/downloads.png)](https://packagist.org/packages/RobLoach/GitHubPagesDeploy)
+[![Latest Stable Version](https://poser.pugx.org/RobLoach/GitHubPagesDeploy/v/stable.png)](https://packagist.org/packages/RobLoach/GitHubPagesDeploy)
+
+Deploys a number of repositories using the `gh-pages` branch, and keep the up to
+date.
+
+## Installation
+
+GitHub Pages Deploy can be installed with [Composer](http://getcomposer.org)
+by adding it as a dependency to your project's composer.json file.
+
+```json
+{
+ "require-dev": {
+ "robloach/gh-pages-deploy": "*"
+ }
+}
+```
+
+Please refer to [Composer's documentation](https://github.com/composer/composer/blob/master/doc/00-intro.md#introduction)
+for more detailed installation and usage instructions.
+
+## Usage
+
+1. Download GitHub Pages Deploy with Composer
+
+``` bash
+$ php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
+$ php composer.phar create-project robloach/php-pages-deploy
+```
+
+2. Create a `gh-pages-deploy.json` file:
+
+``` json
+{
+ "mywebsite": "https://github.com/my/website.git",
+ "myotherwebsite": "https://github.com/my/otherwebsite.git"
+}
+```
+
+3. Execute GitHub Pages Deploy
+
+``` bash
+$ gh-pages-deploy/bin/gh-pages-deploy deploy
+```
diff --git a/bin/gh-pages-deploy b/bin/gh-pages-deploy
new file mode 100755
index 0000000..e323caa
--- /dev/null
+++ b/bin/gh-pages-deploy
@@ -0,0 +1,4 @@
+#!/usr/bin/env php
+<?php
+
+require 'gh-pages-deploy.php';
diff --git a/bin/gh-pages-deploy.php b/bin/gh-pages-deploy.php
new file mode 100644
index 0000000..5b039bc
--- /dev/null
+++ b/bin/gh-pages-deploy.php
@@ -0,0 +1,43 @@
+<?php
+
+if (PHP_SAPI !== 'cli') {
+ echo 'Warning: GitHub Pages Deploy should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
+}
+
+require __DIR__.'/../src/bootstrap.php';
+
+use GitHubPagesDeploy\Console\Application;
+
+error_reporting(-1);
+
+if (function_exists('ini_set')) {
+ @ini_set('display_errors', 1);
+
+ $memoryInBytes = function ($value) {
+ $unit = strtolower(substr($value, -1, 1));
+ $value = (int) $value;
+ switch($unit) {
+ case 'g':
+ $value *= 1024;
+ // no break (cumulative multiplier)
+ case 'm':
+ $value *= 1024;
+ // no break (cumulative multiplier)
+ case 'k':
+ $value *= 1024;
+ }
+
+ return $value;
+ };
+
+ $memoryLimit = trim(ini_get('memory_limit'));
+ // Increase memory_limit if it is lower than 512M
+ if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 512 * 1024 * 1024) {
+ @ini_set('memory_limit', '512M');
+ }
+ unset($memoryInBytes, $memoryLimit);
+}
+
+// run the command application
+$application = new Application();
+$application->run();
diff --git a/box.json b/box.json
new file mode 100644
index 0000000..f424806
--- /dev/null
+++ b/box.json
@@ -0,0 +1,25 @@
+{
+ "chmod": "0755",
+ "directories": ["src", "bin"],
+ "files": [
+ "LICENSE.md",
+ "README.md"
+ ],
+ "finder": [
+ {
+ "name": "*.php",
+ "exclude": [
+ "phing",
+ "test",
+ "tests",
+ "Test",
+ "Tests",
+ "Tester"
+ ],
+ "in": "vendor"
+ }
+ ],
+ "main": "bin/gh-pages-deploy",
+ "output": "gh-pages-deploy.phar",
+ "stub": true
+}
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..6ec3c88
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,28 @@
+{
+ "name": "robloach/gh-pages-deploy",
+ "type": "library",
+ "description": "Deploys a number of repositories using the gh-pages branch.",
+ "homepage": "https://github.com/RobLoach/gh-pages-deploy",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "See contributors",
+ "homepage": "https://github.com/RobLoach/gh-pages-deploy/graphs/contributors"
+ }
+ ],
+ "support": {
+ "issues": "https://github.com/RobLoach/gh-pages-deploy/issues"
+ },
+ "require": {
+ "php": ">=5.3.0",
+ "cpliakas/git-wrapper": "1.2.*"
+ },
+ "autoload": {
+ "psr-0": {
+ "GitHubPagesDeploy": "src/"
+ }
+ },
+ "bin": [
+ "bin/gh-pages-deploy"
+ ]
+}
diff --git a/src/GitHubPagesDeploy/Console/Application.php b/src/GitHubPagesDeploy/Console/Application.php
new file mode 100644
index 0000000..a7791ad
--- /dev/null
+++ b/src/GitHubPagesDeploy/Console/Application.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace GitHubPagesDeploy\Console;
+
+use Symfony\Component\Console\Application as BaseApplication;
+use GitHubPagesDeploy\Console\Command\DeployCommand;
+
+class Application extends BaseApplication
+{
+ const NAME = 'GitHub Pages Deploy';
+ const VERSION = '@package_version@';
+
+ public function __construct()
+ {
+ parent::__construct(static::NAME, static::VERSION);
+ }
+
+ protected function getDefaultCommands()
+ {
+ $defaultCommands = parent::getDefaultCommands();
+ $defaultCommands[] = new DeployCommand();
+ return $defaultCommands;
+ }
+}
diff --git a/src/GitHubPagesDeploy/Console/Command/DeployCommand.php b/src/GitHubPagesDeploy/Console/Command/DeployCommand.php
new file mode 100644
index 0000000..70c7d8a
--- /dev/null
+++ b/src/GitHubPagesDeploy/Console/Command/DeployCommand.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace GitHubPagesDeploy\Console\Command;
+
+use GitHubPagesDeploy\GitHubPagesDeploy;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class DeployCommand extends Command
+{
+ protected function configure()
+ {
+ $this
+ ->setName('deploy')
+ ->setDescription('Deploys the list of GitHub Pages repositories.')
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $deploy = GitHubPagesDeploy::fromFile();
+ $repositories = $deploy->getRepositories();
+ if (empty($repositories)) {
+ $output->writeln('<info>gh-pages-deploy.json is empty.</info>');
+ }
+ else {
+ $deploy->update();
+ }
+ }
+}
diff --git a/src/GitHubPagesDeploy/GitHubPagesDeploy.php b/src/GitHubPagesDeploy/GitHubPagesDeploy.php
new file mode 100644
index 0000000..c7f1a17
--- /dev/null
+++ b/src/GitHubPagesDeploy/GitHubPagesDeploy.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace GitHubPagesDeploy;
+
+use GitWrapper\GitWrapper;
+use GitWrapper\GitWorkingCopy;
+
+class GitHubPagesDeploy
+{
+ protected $repositories;
+
+ public function __construct($repositories = array())
+ {
+ $this->repositories = $repositories;
+ }
+
+ public static function fromFile($file = 'gh-pages-deploy.json')
+ {
+ $results = array();
+
+ if (is_file($file)) {
+ $contents = file_get_contents($file);
+ $results = json_decode($contents);
+ }
+
+ return new GitHubPagesDeploy($results);
+ }
+
+ public function update()
+ {
+ // Create the wrapper.
+ $wrapper = new GitWrapper();
+ $wrapper->streamOutput();
+
+ foreach ($this->repositories as $dir => $repo) {
+ $git = null;
+ if (!is_dir($dir)) {
+ $git = $wrapper->cloneRepository($repo, $dir);
+ }
+ else {
+ $git = new GitWorkingCopy($wrapper, $dir);
+ }
+
+ $git->checkout('gh-pages');
+ $git->pull();
+ }
+ }
+
+ public function getRepositories()
+ {
+ return $this->repositories;
+ }
+}
diff --git a/src/bootstrap.php b/src/bootstrap.php
new file mode 100644
index 0000000..4ffa9d1
--- /dev/null
+++ b/src/bootstrap.php
@@ -0,0 +1,15 @@
+<?php
+
+function includeIfExists($file)
+{
+ return file_exists($file) ? include $file : false;
+}
+
+if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
+ echo 'You must set up the project dependencies, run the following commands:'.PHP_EOL.
+ 'curl -sS https://getcomposer.org/installer | php'.PHP_EOL.
+ 'php composer.phar install'.PHP_EOL;
+ exit(1);
+}
+
+return $loader;