【问题标题】:Deploying different branches using Deployer使用 Deployer 部署不同的分支
【发布时间】:2022-07-14 14:06:19
【问题描述】:

我正在学习使用 Deployer 将我的 Laravel 应用程序部署到登台/生产环境。

下面的配置有效,但它总是部署相同的代码。是否可以将 staging 设置为仅部署 develop 分支,并将生产设置为部署 master 分支?

namespace Deployer;

require 'recipe/laravel.php';

set('application', 'my_app');
set('repository', 'git@github.com:account/repo-name.git');
set('php_fpm_version', '8.0');
set('git_tty', false);

add('shared_files', []);
add('shared_dirs', []);
add('writable_dirs', []);

host('staging')
    ->hostname('hostname-here')
    ->user('username')
    ->identityFile('~/.ssh/id_rsa')
    ->multiplexing(false)
    ->set('deploy_path', '~/staging');

host('production')
    ->hostname('hostname-here')
    ->user('username')
    ->identityFile('~/.ssh/id_rsa')
    ->multiplexing(false)
    ->set('deploy_path', '~/production');

task('build', function () {
    run('cd {{release_path}} && build');
});

after('deploy:failed', 'deploy:unlock');
before('deploy:symlink', 'artisan:migrate');

【问题讨论】:

标签: php laravel php-deployer


【解决方案1】:

您可以在主机配置中使用->set('branch', 'master') 设置分支。

host('staging')
  ->set('branch', 'develop')

host('production')
  ->set('branch', 'master')

【讨论】:

    猜你喜欢
    • 2010-12-04
    • 2017-05-20
    • 2019-08-30
    • 2014-03-02
    • 2018-02-19
    • 1970-01-01
    • 2019-05-12
    • 2020-04-28
    • 1970-01-01
    相关资源
    最近更新 更多