add custom git commit deployment
This commit is contained in:
parent
775ee5d27a
commit
fe6ecd465e
@ -21,7 +21,7 @@ public function configuration()
|
||||
if (!$application) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
return view('project.application.configuration', ['application' => $application]);
|
||||
return view('project.application.configuration', ['application' => $application,]);
|
||||
}
|
||||
public function deployments()
|
||||
{
|
||||
|
@ -19,4 +19,13 @@ public function mount()
|
||||
{
|
||||
$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!');
|
||||
}
|
||||
}
|
||||
|
@ -430,8 +430,8 @@ private function executeNow(
|
||||
}
|
||||
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";
|
||||
|
@ -44,16 +44,23 @@ public function publishDirectory(): Attribute
|
||||
set: 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}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public function up(): void
|
||||
|
||||
$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();
|
||||
|
@ -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>
|
||||
<a
|
||||
|
@ -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>
|
||||
|
@ -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'"
|
||||
|
@ -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>
|
||||
|
@ -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')" />
|
||||
|
Loading…
Reference in New Issue
Block a user