-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDeployerLoader.php
More file actions
44 lines (37 loc) · 1.22 KB
/
DeployerLoader.php
File metadata and controls
44 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
namespace Hypernode\Deploy;
use Deployer\Deployer;
use Hypernode\Deploy\Console\Output\OutputWatcher;
use Hypernode\Deploy\Printer\GithubWorkflowPrinter;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class DeployerLoader
{
private ?Deployer $deployer = null;
public function getOrCreateInstance(OutputInterface $output): Deployer
{
if ($this->deployer) {
return $this->deployer;
}
$console = new Application();
$this->deployer = new Deployer($console);
$this->deployer['output'] = new OutputWatcher($output);
$this->deployer['input'] = new ArrayInput(
[],
new InputDefinition([
new InputOption('limit'),
new InputOption('profile'),
])
);
if (getenv('GITHUB_WORKFLOW')) {
$this->deployer['pop'] = function ($c) {
return new GithubWorkflowPrinter($c['output']);
};
}
return $this->deployer;
}
}