Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanpisa committed Jun 15, 2023
1 parent 32a2968 commit 2ce46a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/Http/Controllers/DeployController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@

class DeployController extends Controller
{
/**
* Handle deployment of the given event.
*/
public function deployEvent(Server $server, string $repository, string $event): JsonResponse
{
$site = match ($event) {
'pull_request' => app(DeployBranchAction::class)->run($server, $repository, request()->input('branch')),
default => app(DeployBranchAction::class)->run($server, $repository, request()->input('number'))
};

if (! $site) {
return response()->json(['success' => false], 409);
}

return response()->json(['success' => true, 'site' => $site]);
}

/**
* Handle deployment of the given branch.
*/
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

Route::middleware(EnsureTokenIsValid::class)->group(function () {
Route::post('deploy/{repository}/event/{event}', [DeployController::class, 'deployEvent']);
Route::post('deploy/{repository}/{branch}', [DeployController::class, 'deployBranch']);
Route::post('deploy/{repository}/pull/{number}', [DeployController::class, 'deployPullRequest']);
});

0 comments on commit 2ce46a2

Please sign in to comment.