Last active
August 29, 2015 14:19
-
-
Save iamlucianojr/4fafa78743081c080d89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment