An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Fix styling
andrasbacsai2e01665340bf
diff --git a/app/Http/Controllers/Webhook/Bitbucket.php b/app/Http/Controllers/Webhook/Bitbucket.phpindex f666d55cc0..059438ff4c 100644--- a/app/Http/Controllers/Webhook/Bitbucket.php+++ b/app/Http/Controllers/Webhook/Bitbucket.php@@ -39,7 +39,7 @@ class Bitbucket extends Controller$x_bitbucket_token = data_get($headers, 'x-hub-signature.0', '');$x_bitbucket_event = data_get($headers, 'x-event-key.0', '');$handled_events = collect(['repo:push', 'pullrequest:created', 'pullrequest:rejected', 'pullrequest:fulfilled']);- if (!$handled_events->contains($x_bitbucket_event)) {+ if (! $handled_events->contains($x_bitbucket_event)) {return response(['status' => 'failed','message' => 'Nothing to do. Event not handled.',@@ -49,13 +49,13 @@ class Bitbucket extends Controller$branch = data_get($payload, 'push.changes.0.new.name');$full_name = data_get($payload, 'repository.full_name');$commit = data_get($payload, 'push.changes.0.new.target.hash');- if (!$branch) {+ if (! $branch) {return response(['status' => 'failed','message' => 'Nothing to do. No branch found in the request.',]);}- ray('Manual webhook bitbucket push event with branch: ' . $branch);+ ray('Manual webhook bitbucket push event with branch: '.$branch);}if ($x_bitbucket_event === 'pullrequest:created' || $x_bitbucket_event === 'pullrequest:rejected' || $x_bitbucket_event === 'pullrequest:fulfilled') {$branch = data_get($payload, 'pullrequest.destination.branch.name');@@ -79,7 +79,7 @@ class Bitbucket extends Controller[$algo, $hash] = explode('=', $x_bitbucket_token, 2);$payloadHash = hash_hmac($algo, $payload, $webhook_secret);- if (!hash_equals($hash, $payloadHash) && !isDev()) {+ if (! hash_equals($hash, $payloadHash) && ! isDev()) {$return_payloads->push(['application' => $application->name,'status' => 'failed',@@ -90,19 +90,19 @@ class Bitbucket extends Controllercontinue;}$isFunctional = $application->destination->server->isFunctional();- if (!$isFunctional) {+ if (! $isFunctional) {$return_payloads->push(['application' => $application->name,'status' => 'failed','message' => 'Server is not functional.',]);- ray('Server is not functional: ' . $application->destination->server->name);+ ray('Server is not functional: '.$application->destination->server->name);continue;}if ($x_bitbucket_event === 'repo:push') {if ($application->isDeployable()) {- ray('Deploying ' . $application->name . ' with branch ' . $branch);+ ray('Deploying '.$application->name.' with branch '.$branch);$deployment_uuid = new Cuid2(7);queue_application_deployment(application: $application,@@ -126,10 +126,10 @@ class Bitbucket extends Controller}if ($x_bitbucket_event === 'pullrequest:created') {if ($application->isPRDeployable()) {- ray('Deploying preview for ' . $application->name . ' with branch ' . $branch . ' and base branch ' . $base_branch . ' and pull request id ' . $pull_request_id);+ ray('Deploying preview for '.$application->name.' with branch '.$branch.' and base branch '.$base_branch.' and pull request id '.$pull_request_id);$deployment_uuid = new Cuid2(7);$found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first();- if (!$found) {+ if (! $found) {if ($application->build_pack === 'dockercompose') {$pr_app = ApplicationPreview::create(['git_type' => 'bitbucket',diff --git a/app/Http/Controllers/Webhook/Github.php b/app/Http/Controllers/Webhook/Github.phpindex 87c7e283ae..a030e31ca3 100644--- a/app/Http/Controllers/Webhook/Github.php+++ b/app/Http/Controllers/Webhook/Github.php@@ -73,7 +73,7 @@ class Github extends Controller$removed_files = data_get($payload, 'commits.*.removed');$modified_files = data_get($payload, 'commits.*.modified');$changed_files = collect($added_files)->concat($removed_files)->concat($modified_files)->unique()->flatten();- ray('Manual Webhook GitHub Push Event with branch: ' . $branch);+ ray('Manual Webhook GitHub Push Event with branch: '.$branch);}if ($x_github_event === 'pull_request') {$action = data_get($payload, 'action');@@ -82,9 +82,9 @@ class Github extends Controller$pull_request_html_url = data_get($payload, 'pull_request.html_url');$branch = data_get($payload, 'pull_request.head.ref');$base_branch = data_get($payload, 'pull_request.base.ref');- ray('Webhook GitHub Pull Request Event with branch: ' . $branch . ' and base branch: ' . $base_branch . ' and pull request id: ' . $pull_request_id);+ ray('Webhook GitHub Pull Request Event with branch: '.$branch.' and base branch: '.$base_branch.' and pull request id: '.$pull_request_id);}- if (!$branch) {+ if (! $branch) {return response('Nothing to do. No branch found in the request.');}$applications = Application::where('git_repository', 'like', "%$full_name%");@@ -103,7 +103,7 @@ class Github extends Controllerforeach ($applications as $application) {$webhook_secret = data_get($application, 'manual_webhook_secret_github');$hmac = hash_hmac('sha256', $request->getContent(), $webhook_secret);- if (!hash_equals($x_hub_signature_256, $hmac) && !isDev()) {+ if (! hash_equals($x_hub_signature_256, $hmac) && ! isDev()) {ray('Invalid signature');$return_payloads->push(['application' => $application->name,@@ -114,7 +114,7 @@ class Github extends Controllercontinue;}$isFunctional = $application->destination->server->isFunctional();- if (!$isFunctional) {+ if (! $isFunctional) {$return_payloads->push(['application' => $application->name,'status' => 'failed',@@ -127,7 +127,7 @@ class Github extends Controllerif ($application->isDeployable()) {$is_watch_path_triggered = $application->isWatchPathsTriggered($changed_files);if ($is_watch_path_triggered || is_null($application->watch_paths)) {- ray('Deploying ' . $application->name . ' with branch ' . $branch);+ ray('Deploying '.$application->name.' with branch '.$branch);$deployment_uuid = new Cuid2(7);queue_application_deployment(application: $application,@@ -169,7 +169,7 @@ class Github extends Controllerif ($application->isPRDeployable()) {$deployment_uuid = new Cuid2(7);$found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first();- if (!$found) {+ if (! $found) {if ($application->build_pack === 'dockercompose') {$pr_app = ApplicationPreview::create(['git_type' => 'github',@@ -290,7 +290,7 @@ class Github extends Controller$webhook_secret = data_get($github_app, 'webhook_secret');$hmac = hash_hmac('sha256', $request->getContent(), $webhook_secret);if (config('app.env') !== 'local') {- if (!hash_equals($x_hub_signature_256, $hmac)) {+ if (! hash_equals($x_hub_signature_256, $hmac)) {return response('Invalid signature.');}}@@ -313,7 +313,7 @@ class Github extends Controller$removed_files = data_get($payload, 'commits.*.removed');$modified_files = data_get($payload, 'commits.*.modified');$changed_files = collect($added_files)->concat($removed_files)->concat($modified_files)->unique()->flatten();- ray('Webhook GitHub Push Event: ' . $id . ' with branch: ' . $branch);+ ray('Webhook GitHub Push Event: '.$id.' with branch: '.$branch);}if ($x_github_event === 'pull_request') {$action = data_get($payload, 'action');@@ -322,9 +322,9 @@ class Github extends Controller$pull_request_html_url = data_get($payload, 'pull_request.html_url');$branch = data_get($payload, 'pull_request.head.ref');$base_branch = data_get($payload, 'pull_request.base.ref');- ray('Webhook GitHub Pull Request Event: ' . $id . ' with branch: ' . $branch . ' and base branch: ' . $base_branch . ' and pull request id: ' . $pull_request_id);+ ray('Webhook GitHub Pull Request Event: '.$id.' with branch: '.$branch.' and base branch: '.$base_branch.' and pull request id: '.$pull_request_id);}- if (!$id || !$branch) {+ if (! $id || ! $branch) {return response('Nothing to do. No id or branch found.');}$applications = Application::where('repository_project_id', $id)->whereRelation('source', 'is_public', false);@@ -343,7 +343,7 @@ class Github extends Controllerforeach ($applications as $application) {$isFunctional = $application->destination->server->isFunctional();- if (!$isFunctional) {+ if (! $isFunctional) {$return_payloads->push(['status' => 'failed','message' => 'Server is not functional.',@@ -357,7 +357,7 @@ class Github extends Controllerif ($application->isDeployable()) {$is_watch_path_triggered = $application->isWatchPathsTriggered($changed_files);if ($is_watch_path_triggered || is_null($application->watch_paths)) {- ray('Deploying ' . $application->name . ' with branch ' . $branch);+ ray('Deploying '.$application->name.' with branch '.$branch);$deployment_uuid = new Cuid2(7);queue_application_deployment(application: $application,@@ -399,7 +399,7 @@ class Github extends Controllerif ($application->isPRDeployable()) {$deployment_uuid = new Cuid2(7);$found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first();- if (!$found) {+ if (! $found) {ApplicationPreview::create(['git_type' => 'github','application_id' => $application->id,diff --git a/app/Http/Controllers/Webhook/Gitlab.php b/app/Http/Controllers/Webhook/Gitlab.phpindex 7ae376f1f7..f6e6cf7e7a 100644--- a/app/Http/Controllers/Webhook/Gitlab.php+++ b/app/Http/Controllers/Webhook/Gitlab.php@@ -40,7 +40,7 @@ class Gitlab extends Controller$x_gitlab_token = data_get($headers, 'x-gitlab-token.0');$x_gitlab_event = data_get($payload, 'object_kind');$allowed_events = ['push', 'merge_request'];- if (!in_array($x_gitlab_event, $allowed_events)) {+ if (! in_array($x_gitlab_event, $allowed_events)) {$return_payloads->push(['status' => 'failed','message' => 'Event not allowed. Only push and merge_request events are allowed.',@@ -55,7 +55,7 @@ class Gitlab extends Controllerif (Str::isMatch('/refs\/heads\/*/', $branch)) {$branch = Str::after($branch, 'refs/heads/');}- if (!$branch) {+ if (! $branch) {$return_payloads->push(['status' => 'failed','message' => 'Nothing to do. No branch found in the request.',@@ -67,7 +67,7 @@ class Gitlab extends Controller$removed_files = data_get($payload, 'commits.*.removed');$modified_files = data_get($payload, 'commits.*.modified');$changed_files = collect($added_files)->concat($removed_files)->concat($modified_files)->unique()->flatten();- ray('Manual Webhook GitLab Push Event with branch: ' . $branch);+ ray('Manual Webhook GitLab Push Event with branch: '.$branch);}if ($x_gitlab_event === 'merge_request') {$action = data_get($payload, 'object_attributes.action');@@ -76,7 +76,7 @@ class Gitlab extends Controller$full_name = data_get($payload, 'project.path_with_namespace');$pull_request_id = data_get($payload, 'object_attributes.iid');$pull_request_html_url = data_get($payload, 'object_attributes.url');- if (!$branch) {+ if (! $branch) {$return_payloads->push(['status' => 'failed','message' => 'Nothing to do. No branch found in the request.',@@ -84,7 +84,7 @@ class Gitlab extends Controllerreturn response($return_payloads);}- ray('Webhook GitHub Pull Request Event with branch: ' . $branch . ' and base branch: ' . $base_branch . ' and pull request id: ' . $pull_request_id);+ ray('Webhook GitHub Pull Request Event with branch: '.$branch.' and base branch: '.$base_branch.' and pull request id: '.$pull_request_id);}$applications = Application::where('git_repository', 'like', "%$full_name%");if ($x_gitlab_event === 'push') {@@ -122,13 +122,13 @@ class Gitlab extends Controllercontinue;}$isFunctional = $application->destination->server->isFunctional();- if (!$isFunctional) {+ if (! $isFunctional) {$return_payloads->push(['application' => $application->name,'status' => 'failed','message' => 'Server is not functional',]);- ray('Server is not functional: ' . $application->destination->server->name);+ ray('Server is not functional: '.$application->destination->server->name);continue;}@@ -136,7 +136,7 @@ class Gitlab extends Controllerif ($application->isDeployable()) {$is_watch_path_triggered = $application->isWatchPathsTriggered($changed_files);if ($is_watch_path_triggered || is_null($application->watch_paths)) {- ray('Deploying ' . $application->name . ' with branch ' . $branch);+ ray('Deploying '.$application->name.' with branch '.$branch);$deployment_uuid = new Cuid2(7);queue_application_deployment(application: $application,@@ -171,7 +171,7 @@ class Gitlab extends Controller'application_uuid' => $application->uuid,'application_name' => $application->name,]);- ray('Deployments disabled for ' . $application->name);+ ray('Deployments disabled for '.$application->name);}}if ($x_gitlab_event === 'merge_request') {@@ -179,7 +179,7 @@ class Gitlab extends Controllerif ($application->isPRDeployable()) {$deployment_uuid = new Cuid2(7);$found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first();- if (!$found) {+ if (! $found) {if ($application->build_pack === 'dockercompose') {$pr_app = ApplicationPreview::create(['git_type' => 'gitlab',@@ -207,7 +207,7 @@ class Gitlab extends Controlleris_webhook: true,git_type: 'gitlab');- ray('Deploying preview for ' . $application->name . ' with branch ' . $branch . ' and base branch ' . $base_branch . ' and pull request id ' . $pull_request_id);+ ray('Deploying preview for '.$application->name.' with branch '.$branch.' and base branch '.$base_branch.' and pull request id '.$pull_request_id);$return_payloads->push(['application' => $application->name,'status' => 'success',@@ -219,7 +219,7 @@ class Gitlab extends Controller'status' => 'failed','message' => 'Preview deployments disabled',]);- ray('Preview deployments disabled for ' . $application->name);+ ray('Preview deployments disabled for '.$application->name);}} elseif ($action === 'closed' || $action === 'close' || $action === 'merge') {$found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first();diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.phpindex ea8a197647..f29cd43ce5 100644--- a/app/Livewire/Project/Application/Previews.php+++ b/app/Livewire/Project/Application/Previews.php@@ -131,10 +131,12 @@ class Previews extends Component}}- public function add_and_deploy(int $pull_request_id, ?string $pull_request_html_url = null) {+ public function add_and_deploy(int $pull_request_id, ?string $pull_request_html_url = null)+ {$this->add($pull_request_id, $pull_request_html_url);$this->deploy($pull_request_id, $pull_request_html_url);}+public function deploy(int $pull_request_id, ?string $pull_request_html_url = null){try {