Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'recipe/common.php';
- /*
- * Servers
- */
- // Set up production server
- server('production-server', 'host.com')
- ->user('root')
- ->path('/webroot/host.com');
- // set up staging server
- server('staging-server', 'host.com')
- ->user('root')
- ->path('/webroot/host.com');
- // set up stages
- stage('staging', ['staging-server'], ['branch' => 'master'], true);
- stage('production', ['production-server'], ['branch' => 'master']);
- /*
- * Variables and settings
- */
- set('shared_dirs', ['storage']);
- set('shared_files', []);
- set('writable_dirs', ['storage']);
- set('permission_method', 'chmod_bad');
- set('repository', 'git repo');
- /*
- * Tasks
- */
- task('deploy:copy_env', function () {
- $releasePath = env()->getReleasePath();
- run("cp current/.env $releasePath/");
- })->description('Copy .env files from previous release');
- task('database:migrate', function () {
- run("php current/artisan migrate --force");
- })->description('Migrating database');
- task('php-fpm:reload', function () {
- run("/usr/sbin/service php5-fpm reload");
- })->description('Reloading PHP5-FPM');
- task('deploy', [
- 'deploy:start',
- 'deploy:prepare',
- 'deploy:update_code',
- 'deploy:shared',
- 'deploy:writable_dirs',
- 'deploy:copy_env',
- 'deploy:vendors',
- 'deploy:symlink',
- 'database:migrate',
- 'cleanup',
- 'deploy:end'
- ])
- ->desc('Deploy your project')
- ->option('branch', 'b', 'Set the deployed branch', 'master');
- /*
- * Hooks
- */
- // read branch from input option before getting code
- before('deploy:update_code', function ($input) {
- $stage = $input->getArgument('stage');
- if ($stage == 'staging' && $input->hasOption('branch')) {
- $branch = $input->getOption('branch', get('branch', null));
- set('branch', $branch);
- }
- });
- // Reload php-fpm after deploy
- after('deploy:end', 'php-fpm:reload');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement