v1.5-alpha.2

This commit is contained in:
carodej
2020-05-16 12:04:28 +02:00
parent 41656235fc
commit d2c4f2aa23
23 changed files with 221 additions and 256 deletions
+63
View File
@@ -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
View File
@@ -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,
];
/**
+27
View File
@@ -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');
}
}
}
+1 -1
View File
@@ -19,6 +19,6 @@ class VerifyCsrfToken extends Middleware
* @var array
*/
protected $except = [
//
'/deploy',
];
}