Compare commits

..

6 Commits
1.1.1 ... 1.2.0

Author SHA1 Message Date
bce05d3171 Merge pull request #148 from vitodeploy/versioning
show current version
2024-04-01 20:50:03 +02:00
929dd1dbaa show version a bit trasparent on mobile 2024-04-01 00:06:29 +02:00
2bcd145bea docker 2024-03-31 23:58:45 +02:00
c0f903d4ca show current version 2024-03-31 23:29:22 +02:00
cca4ab7ae3 fix code editor 2024-03-29 18:40:20 +01:00
51e7325d3d fix trusted procies 2024-03-29 18:25:14 +01:00
16 changed files with 96 additions and 60 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

@ -12,7 +12,7 @@ class TrustProxies extends Middleware
* *
* @var array<int, string>|string|null * @var array<int, string>|string|null
*/ */
protected $proxies; protected $proxies = '*';
/** /**
* The headers that should be used to detect proxies. * The headers that should be used to detect proxies.

View File

@ -7,7 +7,6 @@
use App\Helpers\Toast; use App\Helpers\Toast;
use Illuminate\Contracts\Container\BindingResolutionException; use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Http\Resources\Json\ResourceCollection; use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
@ -37,9 +36,5 @@ public function boot(): void
$this->app->bind('toast', function () { $this->app->bind('toast', function () {
return new Toast; return new Toast;
}); });
if (str(request()->url())->startsWith('https://')) {
URL::forceScheme('https');
}
} }
} }

View File

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

View File

@ -27,9 +27,9 @@ COPY docker/php.ini /etc/php/8.2/cli/conf.d/99-vito.ini
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# app # app
COPY . /var/www/html RUN rm -rf /var/www/html
RUN rm -rf /var/www/html/vendor RUN git clone -b 1.x https://github.com/vitodeploy/vito.git /var/www/html
RUN rm -rf /var/www/html/.env RUN git checkout $(git tag -l --merged 1.x --sort=-v:refname | head -n 1)
RUN composer install --no-dev --prefer-dist RUN composer install --no-dev --prefer-dist
RUN chown -R www-data:www-data /var/www/html \ RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html/storage /var/www/html/bootstrap/cache && chmod -R 755 /var/www/html/storage /var/www/html/bootstrap/cache

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-e3775b0a.css",
"isEntry": true, "isEntry": true,
"src": "resources/css/app.css" "src": "resources/css/app.css"
}, },

View File

@ -11,13 +11,16 @@
disabled: @js($disabled), disabled: @js($disabled),
lang: @js($lang), lang: @js($lang),
init() { init() {
document.body.addEventListener('htmx:afterSettle', (event) => {
let editor = null let editor = null
let theme = let theme =
document.documentElement.className === 'dark' document.documentElement.className === 'dark'
? 'one-dark' ? 'one-dark'
: 'github' : 'github'
editor = window.ace.edit(this.editorId, {}) editor = window.ace.edit(this.editorId, {})
let contentElement = document.getElementById(`text-${this.editorId}`) let contentElement = document.getElementById(
`text-${this.editorId}`,
)
editor.setValue(contentElement.innerText, 1) editor.setValue(contentElement.innerText, 1)
if (this.disabled) { if (this.disabled) {
editor.setReadOnly(true) editor.setReadOnly(true)
@ -33,6 +36,7 @@
theme = event.detail.theme === 'dark' ? 'one-dark' : 'github' theme = event.detail.theme === 'dark' ? 'one-dark' : 'github'
editor.setTheme(`ace/theme/${theme}`) editor.setTheme(`ace/theme/${theme}`)
}) })
})
}, },
}" }"
> >

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/60 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();