Files
Central/src/Service/DeployService.php
tristan 419d3b24cb
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
fix : ajout d'un préfix pour les path des app et correction de l'affichage
2026-04-07 10:30:58 +02:00

56 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Service;
use App\Entity\Environment;
use Symfony\Component\Process\Process;
final readonly class DeployService
{
public function __construct(
private AppPathResolver $pathResolver,
) {}
/**
* @return array{success: bool, output: string, exitCode: int}
*/
public function deploy(Environment $environment, string $tag): array
{
$relativePath = $environment->getDeployScriptPath();
if (null === $relativePath) {
return [
'success' => false,
'output' => 'Deploy script path is not configured.',
'exitCode' => 1,
];
}
$scriptPath = $this->pathResolver->resolve($relativePath);
if (!file_exists($scriptPath)) {
return [
'success' => false,
'output' => sprintf('Deploy script not found: %s', $scriptPath),
'exitCode' => 1,
];
}
$process = new Process(
['bash', $scriptPath, $tag],
dirname($scriptPath),
);
$process->setTimeout(300);
$process->run();
return [
'success' => $process->isSuccessful(),
'output' => $process->getOutput() . $process->getErrorOutput(),
'exitCode' => $process->getExitCode() ?? 1,
];
}
}