deployer
<?php
namespace Deployer;
require 'recipe/laravel.php';
// Project name
set('application', 'test');
// Project repository
set('repository', '仓库地址);
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);
// Writable dirs by web server
add('writable_dirs', []);
set('allow_anonymous_stats', false);
set('writable_mode', 'chmod');
// Hosts
localhost()
->user('仓库用户')
->set('branch', 'dev') // 设置分支
->set('deploy_path', '/var/www/{{application}}')
->set('bin/npm', function () {
return (string)run('which cnpm');
});
// Tasks
desc('Install npm packages');
task('npm:install', function () {
if (has('previous_release')) {
if (test('[ -d {{previous_release}}/node_modules ]')) {
run('cp -R {{previous_release}}/node_modules {{release_path}}');
}
}
run("cd {{release_path}} && {{bin/npm}} install");
});
task('npm:run', function () {
run('cd {{release_path}} && npm run dev');
});
task('deploy:build', [
'npm:install',
'npm:run'
]);
before('deploy:symlink', 'deploy:build');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
请登录