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
add custom git commit deployment
Andras Bacsaife6ecd465e56
diff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.phpindex f477549dbc..450abac73a 100644--- a/app/Http/Controllers/ApplicationController.php+++ b/app/Http/Controllers/ApplicationController.php@@ -21,7 +21,7 @@ class ApplicationController extends Controllerif (!$application) {return redirect()->route('dashboard');}- return view('project.application.configuration', ['application' => $application]);+ return view('project.application.configuration', ['application' => $application,]);}public function deployments(){diff --git a/app/Http/Livewire/Project/Application/Source.php b/app/Http/Livewire/Project/Application/Source.phpindex 56d1c6e866..6876a06601 100644--- a/app/Http/Livewire/Project/Application/Source.php+++ b/app/Http/Livewire/Project/Application/Source.php@@ -19,4 +19,13 @@ class Source extends Component{$this->application = Application::where('id', $this->applicationId)->first();}+ public function submit()+ {+ $this->validate();+ if (!$this->application->git_commit_sha) {+ $this->application->git_commit_sha = 'HEAD';+ }+ $this->application->save();+ $this->emit('saved', 'Application source updated!');+ }}diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.phpindex 08a4d5403c..f4a9f27d93 100644--- a/app/Jobs/DeployApplicationJob.php+++ b/app/Jobs/DeployApplicationJob.php@@ -430,8 +430,8 @@ COPY --from={$this->application->uuid}:{$this->git_commit}-build /app/{$this->ap}private function setGitImportSettings($git_clone_command){- if ($this->application->git_commit_sha) {- $git_clone_command = "{$git_clone_command} && cd {$this->workdir} && git checkout {$this->application->git_commit_sha}";+ if ($this->application->git_commit_sha !== 'HEAD') {+ $git_clone_command = "{$git_clone_command} && cd {$this->workdir} && git -c advice.detachedHead=false checkout {$this->application->git_commit_sha} >/dev/null 2>&1";}if ($this->application->settings->is_git_submodules_allowed) {$git_clone_command = "{$git_clone_command} && cd {$this->workdir} && git submodule update --init --recursive";diff --git a/app/Models/Application.php b/app/Models/Application.phpindex 36cacf1dcf..c1a0576edb 100644--- a/app/Models/Application.php+++ b/app/Models/Application.php@@ -44,16 +44,23 @@ class Application extends BaseModelset: fn ($value) => $value ? '/' . ltrim($value, '/') : null,);}- public function gitLocation(): Attribute+ public function gitBranchLocation(): Attribute{return Attribute::make(get: function () {if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) {- if (is_null($this->git_commit_sha)) {- return "{$this->source->html_url}/{$this->git_repository}/tree/{$this->git_branch}";- } else {- return "{$this->source->html_url}/{$this->git_repository}/tree/{$this->git_commit_sha}";- }+ return "{$this->source->html_url}/{$this->git_repository}/tree/{$this->git_branch}";+ }+ }++ );+ }+ public function gitCommits(): Attribute+ {+ return Attribute::make(+ get: function () {+ if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) {+ return "{$this->source->html_url}/{$this->git_repository}/commits/{$this->git_branch}";}}diff --git a/database/migrations/2023_03_27_081716_create_applications_table.php b/database/migrations/2023_03_27_081716_create_applications_table.phpindex 3badbe69a1..3e5e4ecb09 100644--- a/database/migrations/2023_03_27_081716_create_applications_table.php+++ b/database/migrations/2023_03_27_081716_create_applications_table.php@@ -22,7 +22,7 @@ return new class extends Migration$table->string('git_repository');$table->string('git_branch');- $table->string('git_commit_sha')->nullable();+ $table->string('git_commit_sha')->default('HEAD');$table->string('docker_registry_image_name')->nullable();$table->string('docker_registry_image_tag')->nullable();diff --git a/resources/views/components/applications/navbar.blade.php b/resources/views/components/applications/navbar.blade.phpindex 266d8380a5..e34d57df0c 100644--- a/resources/views/components/applications/navbar.blade.php+++ b/resources/views/components/applications/navbar.blade.php@@ -1,5 +1,5 @@<nav class="flex gap-4 py-2">- <a target="_blank" href="{{ $gitLocation }}">+ <a target="_blank" href="{{ $gitBranchLocation }}"><x-inputs.button>Open on Git ↗️</x-inputs.button></a><adiff --git a/resources/views/livewire/project/application/source.blade.php b/resources/views/livewire/project/application/source.blade.phpindex 0de4f21c03..91c99e3ff0 100644--- a/resources/views/livewire/project/application/source.blade.php+++ b/resources/views/livewire/project/application/source.blade.php@@ -4,6 +4,12 @@<div class="flex flex-col w-96"><x-inputs.input id="application.git_repository" label="Git Repository" readonly /><x-inputs.input id="application.git_branch" label="Git Branch" readonly />- <x-inputs.input id="application.git_commit_sha" label="Git Commit SHA" readonly />+ <form wire:submit.prevent='submit'>+ <x-inputs.input id="application.git_commit_sha" placeholder="HEAD" label="Git Commit SHA" />+ <x-inputs.button type="submit">Save</x-inputs.button>+ </form>+ <a target="_blank" href="{{ $application->gitCommits }}">+ <x-inputs.button>Commits ↗️</x-inputs.button>+ </a></div></div>diff --git a/resources/views/project/application/configuration.blade.php b/resources/views/project/application/configuration.blade.phpindex 47d5dafff2..b645e283b7 100644--- a/resources/views/project/application/configuration.blade.php+++ b/resources/views/project/application/configuration.blade.php@@ -1,6 +1,6 @@<x-layout><h1>Configuration</h1>- <x-applications.navbar :applicationId="$application->id" :gitLocation="$application->gitLocation" />+ <x-applications.navbar :applicationId="$application->id" :gitBranchLocation="$application->gitBranchLocation" /><div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'general' }"><div class="flex gap-4"><a :class="activeTab === 'general' && 'text-purple-500'"diff --git a/resources/views/project/application/deployment.blade.php b/resources/views/project/application/deployment.blade.phpindex 26fe2acbfe..39be4e283b 100644--- a/resources/views/project/application/deployment.blade.php+++ b/resources/views/project/application/deployment.blade.php@@ -1,5 +1,5 @@<x-layout><h1>Deployment</h1>- <x-applications.navbar :applicationId="$application->id" :gitLocation="$application->gitLocation" />+ <x-applications.navbar :applicationId="$application->id" :gitBranchLocation="$application->gitBranchLocation" /><livewire:project.application.poll-deployment :activity="$activity" :deployment_uuid="$deployment_uuid" /></x-layout>diff --git a/resources/views/project/application/deployments.blade.php b/resources/views/project/application/deployments.blade.phpindex fd4f0bc9b7..0714e23eb9 100644--- a/resources/views/project/application/deployments.blade.php+++ b/resources/views/project/application/deployments.blade.php@@ -1,6 +1,6 @@<x-layout><h1>Deployments</h1>- <x-applications.navbar :applicationId="$application->id" :gitLocation="$application->gitLocation" />+ <x-applications.navbar :applicationId="$application->id" :gitBranchLocation="$application->gitBranchLocation" /><div class="pt-2">@forelse ($deployments as $deployment)<livewire:project.application.get-deployments :deployment_uuid="data_get($deployment->properties, 'type_uuid')" :created_at="data_get($deployment, 'created_at')" :status="data_get($deployment->properties, 'status')" />