deployment script variables (#238)

This commit is contained in:
Saeed Vaziry
2024-06-17 01:12:46 +03:30
committed by GitHub
parent eec83f577c
commit 7d367465ff
4 changed files with 52 additions and 9 deletions

View File

@ -140,19 +140,23 @@ public function tail(string $path, int $lines): string
);
}
public function runScript(string $path, string $script, ?ServerLog $serverLog, ?string $user = null): ServerLog
public function runScript(string $path, string $script, ?ServerLog $serverLog, ?string $user = null, ?array $variables = []): ServerLog
{
$ssh = $this->server->ssh($user);
if ($serverLog) {
$ssh->setLog($serverLog);
}
$ssh->exec(
$this->getScript('run-script.sh', [
'path' => $path,
'script' => $script,
]),
'run-script'
);
$command = '';
foreach ($variables as $key => $variable) {
$command .= "$key=$variable".PHP_EOL;
}
$command .= $this->getScript('run-script.sh', [
'path' => $path,
'script' => $script,
]);
$ssh->exec($command, 'run-script');
info($command);
return $ssh->log;
}