Implement Keystone environment deployments
This commit is contained in:
20
app/Actions/Environments/BuildMigrationScript.php
Normal file
20
app/Actions/Environments/BuildMigrationScript.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Environments;
|
||||
|
||||
use App\Models\Service;
|
||||
|
||||
class BuildMigrationScript
|
||||
{
|
||||
public function execute(Service $service, bool $respectAutomaticMode = true): string
|
||||
{
|
||||
if ($respectAutomaticMode && in_array($service->config['migration_mode'] ?? 'auto', ['disabled', 'manual'], true)) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
$command = $service->config['migration_command'] ?? 'php artisan migrate --force';
|
||||
$serviceKey = str($service->name)->slug('_')->value() ?: 'service';
|
||||
|
||||
return "docker compose -f /home/keystone/services/{$service->id}/compose.yml run --rm {$serviceKey} {$command}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user