show current version

This commit is contained in:
Saeed Vaziry 2024-03-31 23:29:22 +02:00
parent cca4ab7ae3
commit c0f903d4ca
12 changed files with 67 additions and 30 deletions

View File

@ -1,10 +1,11 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers\API;
use App\Actions\Site\Deploy; use App\Actions\Site\Deploy;
use App\Exceptions\SourceControlIsNotConnected; use App\Exceptions\SourceControlIsNotConnected;
use App\Facades\Notifier; use App\Facades\Notifier;
use App\Http\Controllers\Controller;
use App\Models\GitHook; use App\Models\GitHook;
use App\Models\ServerLog; use App\Models\ServerLog;
use App\Notifications\SourceControlDisconnected; use App\Notifications\SourceControlDisconnected;

View File

@ -0,0 +1,16 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
class HealthController extends Controller
{
public function __invoke()
{
return response()->json([
'success' => true,
'version' => vito_version(),
]);
}
}

View File

@ -29,3 +29,8 @@ function htmx(): HtmxResponse
{ {
return new HtmxResponse(); return new HtmxResponse();
} }
function vito_version(): string
{
return exec('git describe --tags');
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"resources/css/app.css": { "resources/css/app.css": {
"file": "assets/app-2c6e7578.css", "file": "assets/app-b6661245.css",
"isEntry": true, "isEntry": true,
"src": "resources/css/app.css" "src": "resources/css/app.css"
}, },

View File

@ -1,9 +1,12 @@
<nav <nav
class="fixed top-0 z-50 flex h-[64px] w-full items-center border-b border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800" class="fixed top-0 z-50 flex h-[64px] w-full items-center border-b border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800"
> >
<div class="w-full px-3 py-3 lg:px-5 lg:pl-3"> <div class="w-full">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div class="flex items-center justify-start"> <div class="flex items-center justify-start">
<div
class="flex items-center justify-start border-r border-gray-200 px-3 py-3 dark:border-gray-700 md:w-64"
>
<button <button
data-drawer-target="logo-sidebar" data-drawer-target="logo-sidebar"
data-drawer-toggle="logo-sidebar" data-drawer-toggle="logo-sidebar"
@ -15,12 +18,17 @@ class="inline-flex items-center rounded-md p-2 text-sm text-gray-500 hover:bg-gr
<x-heroicon name="o-bars-3-center-left" class="h-6 w-6" /> <x-heroicon name="o-bars-3-center-left" class="h-6 w-6" />
</button> </button>
<a href="/" class="ms-2 flex md:me-24"> <a href="/" class="ms-2 flex md:me-24">
<div class="flex items-center justify-start text-3xl font-extrabold"> <div class="relative flex items-center justify-start text-3xl font-extrabold">
<x-application-logo class="h-9 w-9 rounded-md" /> <x-application-logo class="h-9 w-9 rounded-md" />
<span class="ml-1 hidden sm:block">Deploy</span> <span class="ml-1 hidden md:block">Deploy</span>
<span
class="absolute bottom-0 left-0 right-0 rounded-b-md bg-gray-700 text-center text-xs text-white md:relative md:ml-1 md:block md:bg-inherit md:text-inherit"
>
{{ vito_version() }}
</span>
</div> </div>
</a> </a>
<div class="h-[64px] w-1 border-r border-gray-200 px-3 dark:border-gray-700 md:px-0"></div> </div>
<div class="ml-5 cursor-pointer" x-data=""> <div class="ml-5 cursor-pointer" x-data="">
<div <div
class="flex w-full items-center rounded-md border border-gray-200 bg-gray-100 px-4 py-2 text-sm text-gray-900 focus:ring-4 focus:ring-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:focus:ring-gray-600" class="flex w-full items-center rounded-md border border-gray-200 bg-gray-100 px-4 py-2 text-sm text-gray-900 focus:ring-4 focus:ring-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:focus:ring-gray-600"
@ -31,7 +39,7 @@ class="flex w-full items-center rounded-md border border-gray-200 bg-gray-100 px
</div> </div>
</div> </div>
</div> </div>
<div class="flex items-center"> <div class="flex items-center px-3 py-3">
<div class="mr-3"> <div class="mr-3">
@include("layouts.partials.color-scheme") @include("layouts.partials.color-scheme")
</div> </div>

View File

@ -137,8 +137,8 @@
x-on:click="close" x-on:click="close"
class="fixed inset-0 bottom-0 left-0 right-0 top-0 z-[1000] items-center bg-gray-500 opacity-75 dark:bg-gray-900" class="fixed inset-0 bottom-0 left-0 right-0 top-0 z-[1000] items-center bg-gray-500 opacity-75 dark:bg-gray-900"
></div> ></div>
<div class="absolute z-[1000] mt-20 lg:scale-110"> <div class="absolute left-1 right-1 z-[1000] mt-20 md:left-auto md:right-auto lg:scale-110">
<div class="w-[500px]"> <div class="w-full px-10 md:w-[500px]">
<x-text-input <x-text-input
id="search-input" id="search-input"
x-ref="input" x-ref="input"

View File

@ -1,7 +1,9 @@
<?php <?php
// git hook // git hook
use App\Http\Controllers\GitHookController; use App\Http\Controllers\API\GitHookController;
use App\Http\Controllers\API\HealthController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
Route::any('git-hooks', GitHookController::class)->name('git-hooks'); Route::get('health', HealthController::class)->name('api.health');
Route::any('git-hooks', GitHookController::class)->name('api.git-hooks');

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
export VITO_VERSION="1.x"
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
export NEEDRESTART_MODE=a export NEEDRESTART_MODE=a
@ -151,11 +152,13 @@ ln -s /etc/nginx/sites-available/vito /etc/nginx/sites-enabled/
service nginx restart service nginx restart
rm -rf /home/${V_USERNAME}/vito rm -rf /home/${V_USERNAME}/vito
git config --global core.fileMode false git config --global core.fileMode false
git clone -b 1.x ${V_REPO} /home/${V_USERNAME}/vito git clone -b ${VITO_VERSION} ${V_REPO} /home/${V_USERNAME}/vito
find /home/${V_USERNAME}/vito -type d -exec chmod 755 {} \; find /home/${V_USERNAME}/vito -type d -exec chmod 755 {} \;
find /home/${V_USERNAME}/vito -type f -exec chmod 644 {} \; find /home/${V_USERNAME}/vito -type f -exec chmod 644 {} \;
cd /home/${V_USERNAME}/vito && git config core.fileMode false cd /home/${V_USERNAME}/vito && git config core.fileMode false
cd /home/${V_USERNAME}/vito && composer install --no-dev cd /home/${V_USERNAME}/vito
git checkout $(git tag -l --merged ${VITO_VERSION} --sort=-v:refname | head -n 1)
composer install --no-dev
cp .env.prod .env cp .env.prod .env
touch /home/${V_USERNAME}/vito/storage/database.sqlite touch /home/${V_USERNAME}/vito/storage/database.sqlite
php artisan key:generate php artisan key:generate

View File

@ -4,7 +4,9 @@ cd /home/vito/vito
php artisan down php artisan down
git pull git fetch --all
git checkout $(git tag -l --merged 1.x --sort=-v:refname | head -n 1)
composer install --no-dev composer install --no-dev

View File

@ -212,7 +212,7 @@ public function test_git_hook_deployment(): void
'content' => 'git pull', 'content' => 'git pull',
]); ]);
$this->post(route('git-hooks'), [ $this->post(route('api.git-hooks'), [
'secret' => 'secret', 'secret' => 'secret',
])->assertSessionDoesntHaveErrors(); ])->assertSessionDoesntHaveErrors();
@ -240,7 +240,7 @@ public function test_git_hook_deployment_invalid_secret(): void
'content' => 'git pull', 'content' => 'git pull',
]); ]);
$this->post(route('git-hooks'), [ $this->post(route('api.git-hooks'), [
'secret' => 'invalid-secret', 'secret' => 'invalid-secret',
])->assertNotFound(); ])->assertNotFound();