mirror of https://github.com/hauke68/Magallanes
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
9 years ago
|
<?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\Task\BuiltIn\Deploy;
|
||
|
|
||
9 years ago
|
use Mage\Task\Exception\ErrorException;
|
||
9 years ago
|
use Mage\Task\ExecuteOnRollbackInterface;
|
||
|
use Symfony\Component\Process\Process;
|
||
|
use Mage\Task\AbstractTask;
|
||
|
|
||
|
/**
|
||
|
* Release Task - Create the Symlink
|
||
|
*
|
||
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||
|
*/
|
||
|
class ReleaseTask extends AbstractTask implements ExecuteOnRollbackInterface
|
||
|
{
|
||
|
public function getName()
|
||
|
{
|
||
|
return 'deploy/release';
|
||
|
}
|
||
|
|
||
|
public function getDescription()
|
||
|
{
|
||
|
return '[Release] Creating Symlink';
|
||
|
}
|
||
|
|
||
|
public function execute()
|
||
|
{
|
||
9 years ago
|
if (!$this->runtime->getEnvironmentConfig('releases', false)) {
|
||
|
throw new ErrorException('This task is only available with releases enabled', 40);
|
||
|
}
|
||
|
|
||
9 years ago
|
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||
|
$releaseId = $this->runtime->getReleaseId();
|
||
|
|
||
|
$cmdLinkRelease = sprintf('cd %s && ln -snf releases/%s current', $hostPath, $releaseId);
|
||
|
|
||
|
/** @var Process $process */
|
||
|
$process = $this->runtime->runRemoteCommand($cmdLinkRelease, false);
|
||
|
return $process->isSuccessful();
|
||
|
}
|
||
|
}
|