feat: add deploy API endpoints

This commit is contained in:
F4ilji
2026-07-02 12:48:09 +05:00
parent c216f929d4
commit 73d123a62d
3 changed files with 55 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
namespace App\Containers\Dashboard\UI\API\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Process;
class DeployController extends Controller
{
private string $statusFile = '/tmp/deploy-status.json';
private string $lockFile = '/tmp/deploy.lock';
public function store(): JsonResponse
{
if (File::exists($this->lockFile)) {
return response()->json([
'error' => 'Deploy already in progress'
], 409);
}
Process::run('nohup php artisan deploy:run > /dev/null 2>&1 &');
return response()->json(['message' => 'Deploy started']);
}
public function status(): JsonResponse
{
if (!File::exists($this->statusFile)) {
return response()->json([
'running' => false,
'step' => 0,
'total_steps' => 12,
'current_step' => '',
'logs' => [],
'error' => null,
]);
}
$status = json_decode(File::get($this->statusFile), true);
return response()->json($status);
}
}