mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
Add endpoint for triggering site deployment (#563)
* feat(api): Add endpoint for triggering site deployment - Add POST /api/projects/{project}/servers/{server}/sites/{site}/deploy endpoint - Add feature tests * fix merge issue and generate api docs * fix merge --------- Co-authored-by: Saeed Vaziry <61919774+saeedvaziry@users.noreply.github.com> Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature\API;
|
||||
|
||||
use App\Enums\DeploymentStatus;
|
||||
use App\Enums\LoadBalancerMethod;
|
||||
use App\Enums\SourceControl;
|
||||
use App\Facades\SSH;
|
||||
@ -190,6 +191,54 @@ public function test_update_load_balancer(): void
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_deploy_site(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
Http::fake([
|
||||
'https://api.github.com/repos/*' => Http::response([
|
||||
'commit' => [
|
||||
'sha' => 'abc123',
|
||||
'commit' => [
|
||||
'message' => 'Test commit',
|
||||
'author' => [
|
||||
'name' => 'Test Author',
|
||||
'email' => 'test@example.com',
|
||||
'date' => now()->toIso8601String(),
|
||||
],
|
||||
],
|
||||
],
|
||||
], 200),
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||
|
||||
/** @var Site $site */
|
||||
$site = Site::factory()->create([
|
||||
'server_id' => $this->server->id,
|
||||
]);
|
||||
|
||||
$script = $site->deploymentScript;
|
||||
$script->content = 'git pull';
|
||||
$script->save();
|
||||
|
||||
$this->json('POST', route('api.projects.servers.sites.deploy', [
|
||||
'project' => $this->server->project,
|
||||
'server' => $this->server,
|
||||
'site' => $site,
|
||||
]))
|
||||
->assertSuccessful()
|
||||
->assertJsonStructure([
|
||||
'id',
|
||||
'status',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('deployments', [
|
||||
'site_id' => $site->id,
|
||||
'status' => DeploymentStatus::FINISHED,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_update_deployment_script(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
Reference in New Issue
Block a user