1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the Magallanes package. |
4
|
|
|
* |
5
|
|
|
* (c) Andrés Montañez <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Mage\Task\BuiltIn\Deploy; |
12
|
|
|
|
13
|
|
|
use Mage\Task\Exception\ErrorException; |
14
|
|
|
use Mage\Task\ExecuteOnRollbackInterface; |
15
|
|
|
use Symfony\Component\Process\Process; |
16
|
|
|
use Mage\Task\AbstractTask; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Release Task - Create the Symlink |
20
|
|
|
* |
21
|
|
|
* @author Andrés Montañez <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class ReleaseTask extends AbstractTask implements ExecuteOnRollbackInterface |
24
|
|
|
{ |
25
|
|
|
public function getName() |
26
|
|
|
{ |
27
|
|
|
return 'deploy/release'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function getDescription() |
31
|
|
|
{ |
32
|
|
|
return '[Release] Creating Symlink'; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function execute() |
36
|
|
|
{ |
37
|
|
|
if (!$this->runtime->getEnvOption('releases', false)) { |
38
|
|
|
throw new ErrorException('This task is only available with releases enabled', 40); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/'); |
42
|
|
|
$releaseId = $this->runtime->getReleaseId(); |
43
|
|
|
|
44
|
|
|
$cmdLinkRelease = sprintf('cd %s && ln -snf releases/%s current', $hostPath, $releaseId); |
45
|
|
|
|
46
|
|
|
/** @var Process $process */ |
47
|
|
|
$process = $this->runtime->runRemoteCommand($cmdLinkRelease, false, null); |
48
|
|
|
return $process->isSuccessful(); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|