mirror of
https://github.com/hauke68/Magallanes.git
synced 2025-09-13 12:40:18 +02:00
Add Rollback command as alias.
This commit is contained in:
parent
e01fbc6151
commit
17ebb5b30d
57
Mage/Command/BuiltIn/RollbackCommand.php
Normal file
57
Mage/Command/BuiltIn/RollbackCommand.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of the Magallanes package.
|
||||||
|
*
|
||||||
|
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Mage\Command\BuiltIn;
|
||||||
|
|
||||||
|
use Mage\Command\AbstractCommand;
|
||||||
|
use Mage\Command\RequiresEnvironment;
|
||||||
|
use Mage\Task\Factory;
|
||||||
|
use Mage\Console;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an Alias of "release rollback"
|
||||||
|
*
|
||||||
|
* @author Andrés Montañez <andres@andresmontanez.com>
|
||||||
|
*/
|
||||||
|
class RollbackCommand extends AbstractCommand implements RequiresEnvironment
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Rollback a release
|
||||||
|
* @see \Mage\Command\AbstractCommand::run()
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$releaseId = $this->getConfig()->getArgument(1);
|
||||||
|
$lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
|
||||||
|
if (file_exists($lockFile) && ($subcommand == 'rollback')) {
|
||||||
|
Console::output('<red>This environment is locked!</red>', 1, 2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run Tasks for Deployment
|
||||||
|
$hosts = $this->getConfig()->getHosts();
|
||||||
|
|
||||||
|
if (count($hosts) == 0) {
|
||||||
|
Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 1, 3);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
foreach ($hosts as $host) {
|
||||||
|
$this->getConfig()->setHost($host);
|
||||||
|
|
||||||
|
$task = Factory::get('releases/rollback', $this->getConfig());
|
||||||
|
$task->init();
|
||||||
|
$task->setRelease($releaseId);
|
||||||
|
$result = $task->run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user