mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-20 12:15:02 +00:00
v1.5-alpha.2
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Deploy extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'deploy:production';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Automatic deployment for production';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// Start deployment
|
||||
$this->info('Running auto deployment');
|
||||
$this->call('down');
|
||||
|
||||
// Exec commands
|
||||
exec('git pull origin dev');
|
||||
exec('composer install --no-interaction --no-dev --prefer-dist');
|
||||
$this->migrateDatabase();
|
||||
|
||||
// Stop deployment
|
||||
$this->call('up');
|
||||
$this->info('Everything is done, congratulations! 🥳🥳🥳');
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate database
|
||||
*/
|
||||
public function migrateDatabase()
|
||||
{
|
||||
$this->call('migrate', [
|
||||
'--force' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Console\Commands\Deploy;
|
||||
use App\Console\Commands\SetupDevEnvironment;
|
||||
use App\Console\Commands\SetupProductionEnvironment;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
@@ -17,6 +18,7 @@ class Kernel extends ConsoleKernel
|
||||
protected $commands = [
|
||||
SetupProductionEnvironment::class,
|
||||
SetupDevEnvironment::class,
|
||||
Deploy::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Artisan;
|
||||
|
||||
class DeployController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get web hook payload and verify request
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function deploy(Request $request) {
|
||||
|
||||
$githubPayload = $request->getContent();
|
||||
$localToken = config('app.deploy_secret');
|
||||
|
||||
$localHash = 'sha1=' . hash_hmac('sha1', $githubPayload, $localToken, false);
|
||||
|
||||
if (hash_equals( $request->header('X-Hub-Signature'), $localHash)) {
|
||||
|
||||
Artisan::call('deploy:production');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,6 @@ class VerifyCsrfToken extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'/deploy',
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user