-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the possibility to deploy from the remote server to the path's server. Add somes tests.
- Loading branch information
Showing
30 changed files
with
859 additions
and
318 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Automate package. | ||
* | ||
* (c) Julien Jacottet <jjacottet@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Automate\Command; | ||
|
||
use Automate\Loader; | ||
use Automate\Context\LocalContext; | ||
use Automate\Model\Platform; | ||
use Automate\Model\Server; | ||
use Automate\VariableResolver; | ||
use Automate\Workflow\Deployer; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
class LocalDeployCommand extends BaseCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('run') | ||
->setDescription('Start local deployment.') | ||
->addArgument('path', InputArgument::REQUIRED, 'Project\'s local path') | ||
->addArgument('gitRef', InputArgument::REQUIRED, 'Branch or tag name') | ||
->addOption('max-releases', null, InputOption::VALUE_REQUIRED, 'The number of releases to be kept', 3) | ||
->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Configuration file path', self::CONFIG_FILE) | ||
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force to deploy') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$loader = new Loader(); | ||
$project = $loader->load($input->getOption('config')); | ||
|
||
$platform = $this->createLocalPlatforme($input->getArgument('path'), $input->getOption('max-releases')); | ||
|
||
$io = new SymfonyStyle($input, $output); | ||
|
||
$variableResolver = new VariableResolver($io); | ||
$variableResolver->resolveRepository($project); | ||
|
||
$logger = $this->getLogger($io); | ||
|
||
$logger->section('Start local deployment'); | ||
|
||
$gitRef = $input->getArgument('gitRef'); | ||
|
||
$io->table(array(), array( | ||
array('Repository', $project->getRepository()), | ||
array('Version', $input->getArgument('gitRef') ?: $platform->getDefaultBranch()), | ||
)); | ||
|
||
$context = new LocalContext($project, $platform, $gitRef, $logger, $input->getOption('force')); | ||
$workflow = new Deployer($context); | ||
|
||
if (!$workflow->deploy()) { | ||
throw new \RuntimeException('Deployment failed'); | ||
} | ||
|
||
$io->success('All is OK'); | ||
} | ||
|
||
private function createLocalPlatforme($path, $maxReleases) | ||
{ | ||
$serveur = new Server(); | ||
$serveur | ||
->setPath($path) | ||
->setName('local') | ||
; | ||
|
||
$platform = new Platform(); | ||
$platform->setMaxReleases($maxReleases); | ||
$platform->addServer($serveur); | ||
return $platform; | ||
} | ||
} |
Oops, something went wrong.