diff --git a/.idea/php.xml b/.idea/php.xml index ec40896..d81a23b 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -124,6 +124,7 @@ + diff --git a/.idea/portal.iml b/.idea/portal.iml index ccb8e5a..c3981c6 100644 --- a/.idea/portal.iml +++ b/.idea/portal.iml @@ -32,6 +32,7 @@ + diff --git a/Envoy.blade.php b/Envoy.blade.php index b3d9bbc..d0f2eb3 100644 --- a/Envoy.blade.php +++ b/Envoy.blade.php @@ -1 +1,70 @@ -load(); + + $config = new \StdClass; + $config->test_path = "/var/www/html/portal"; + $config->prod_path = "/var/www/html/portal"; + $config->test_branch = "development"; + $config->prod_branch = "production"; + $date = ( new DateTime )->format('Y-m-d H:i:s'); + $dateSave = ( new DateTime )->format('Ymd-Hi'); + $db_host = $_ENV['DB_DATABASE']; + $db_user = $_ENV['DB_USERNAME']; + $db_pass = $_ENV['DB_PASSWORD']; + $rsync = $_ENV['RSYNC_SAV']; + $slack = $_ENV['SLACK_URL']; + +@endsetup + +@servers(['test' => ['raspitest'], 'prod' => ['raspigate']]) + +@story('deploy') + sql-backup + deploy-prod +@endstory + +@task('sql-backup', ['on' => ['prod']]) + cd {{ $config->prod_path }} + mysqldump --user={{ $db_user }} --password={{ $db_pass }} -B {{ $db_host }} > storage/logs/database/save-{{ $db_host }}-{{ $dateSave }}.sql + scp -p storage/logs/database/save-{{ $db_host }}-{{ $dateSave }}.sql {{ $rsync }} +@endtask + +@task('deploy-test', ['on' => ['test']]) + + cd {{ $config->test_path }} +{{-- php artisan down--}} +{{-- git reset --hard HEAD--}} +{{-- git pull origin {{ $config->test_branch }}--}} +{{-- composer install--}} +{{-- npm install--}} +{{-- npm run production--}} +{{-- php artisan migrate --force--}} +{{-- php artisan cache:clear--}} +{{-- php artisan config:cache--}} +{{-- php artisan view:clear--}} +{{-- php artisan optimize--}} +{{-- php artisan up--}} + +@endtask + +@task('deploy-prod', ['on' => ['prod']]) + + cd {{ $config->prod_path }} + php artisan down + git reset --hard HEAD + git pull origin {{ $config->prod_branch }} + composer install + npm install + npm run production + php artisan migrate --force + php artisan optimize + php artisan up + +@endtask + +@finished + @slack($slack, '#envoy', "Deployment on prod: {$date} complete") +@endfinished diff --git a/composer.json b/composer.json index 9a0b890..62b9e1e 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,10 @@ "laravel/framework": "^8.0", "laravel/legacy-factories": "^1.0", "laravel/passport": "^10.0", + "laravel/slack-notification-channel": "^2.2", "laravel/tinker": "^2.0", - "laravel/ui": "^2.0" + "laravel/ui": "^2.0", + "vlucas/phpdotenv": "^5.2" }, "require-dev": { "facade/ignition": "^2.3.6", diff --git a/composer.lock b/composer.lock index aa47f38..0866a81 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1a08ea37954efebb7e59951b5d396e76", + "content-hash": "51b55f3b06042805d19c911a3a4456a7", "packages": [ { "name": "asm89/stack-cors", @@ -1285,6 +1285,63 @@ ], "time": "2020-09-08T15:27:48+00:00" }, + { + "name": "laravel/slack-notification-channel", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/slack-notification-channel.git", + "reference": "98e0fe5c8dda645e6af914285af7b742e167462a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/slack-notification-channel/zipball/98e0fe5c8dda645e6af914285af7b742e167462a", + "reference": "98e0fe5c8dda645e6af914285af7b742e167462a", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0|^7.0", + "illuminate/notifications": "~5.8.0|^6.0|^7.0|^8.0", + "php": "^7.1.3" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^7.0|^8.0|^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + }, + "laravel": { + "providers": [ + "Illuminate\\Notifications\\SlackChannelServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Notifications\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Slack Notification Channel for laravel.", + "keywords": [ + "laravel", + "notifications", + "slack" + ], + "time": "2020-08-25T18:21:34+00:00" + }, { "name": "laravel/tinker", "version": "v2.4.2", @@ -5409,16 +5466,16 @@ }, { "name": "vlucas/phpdotenv", - "version": "v5.1.0", + "version": "v5.2.0", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "448c76d7a9e30c341ff5bc367a923af74ae18467" + "reference": "fba64139db67123c7a57072e5f8d3db10d160b66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/448c76d7a9e30c341ff5bc367a923af74ae18467", - "reference": "448c76d7a9e30c341ff5bc367a923af74ae18467", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/fba64139db67123c7a57072e5f8d3db10d160b66", + "reference": "fba64139db67123c7a57072e5f8d3db10d160b66", "shasum": "" }, "require": { @@ -5441,7 +5498,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.1-dev" + "dev-master": "5.2-dev" } }, "autoload": { @@ -5481,7 +5538,7 @@ "type": "tidelift" } ], - "time": "2020-07-14T19:26:25+00:00" + "time": "2020-09-14T15:57:31+00:00" }, { "name": "voku/portable-ascii",