1
0
mirror of https://github.com/hauke68/Magallanes.git synced 2025-09-13 04:30:17 +02:00
Magallanes/Mage/Task/Releases.php

71 lines
1.9 KiB
PHP
Raw Normal View History

2012-01-01 16:36:41 +01:00
<?php
class Mage_Task_Releases
{
private $_config = null;
private $_action = null;
2012-01-01 21:10:25 +01:00
private $_release = null;
2012-01-01 16:36:41 +01:00
public function setAction($action)
{
$this->_action = $action;
return $this;
}
2012-01-01 16:36:41 +01:00
public function getAction()
{
return $this->_action;
}
2012-01-01 21:10:25 +01:00
public function setRelease($releaseId)
{
$this->_release = $releaseId;
return $this;
}
2012-01-01 21:10:25 +01:00
public function getRelease()
{
return $this->_release;
}
2012-01-01 16:36:41 +01:00
public function run(Mage_Config $config)
{
$this->_config = $config;
2012-09-20 00:16:52 +02:00
if ($config->getEnvironmentName() == '') {
Mage_Console::output('<red>You must specify an environment</red>', 0, 2);
return;
2012-09-20 00:16:52 +02:00
}
$lockFile = '.mage/' . $config->getEnvironmentName() . '.lock';
if (file_exists($lockFile)) {
Mage_Console::output('<red>This environment is locked!</red>', 0, 2);
return;
}
2012-01-01 16:36:41 +01:00
// Run Tasks for Deployment
$hosts = $config->getHosts();
2012-01-01 16:36:41 +01:00
if (count($hosts) == 0) {
Mage_Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 1, 3);
2012-01-01 16:36:41 +01:00
} else {
foreach ($hosts as $host) {
$config->setHost($host);
2012-01-01 16:36:41 +01:00
switch ($this->getAction()) {
case 'list':
$task = Mage_Task_Factory::get('releases/list', $config);
2012-01-01 16:36:41 +01:00
$task->init();
$result = $task->run();
break;
2012-01-01 21:10:25 +01:00
case 'rollback':
$task = Mage_Task_Factory::get('releases/rollback', $config);
$task->init();
$task->setRelease($this->getRelease());
$result = $task->run();
break;
2012-01-01 16:36:41 +01:00
}
}
}
}
}