3

I am learning to use Deployer to deploy my Laravel application to staging / production environments.

The below config works, but it always deploys the same code. Is it possible to set staging to only deploy the develop branch, and set production to deploy the master branch?

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');
CodeSauce
  • 255
  • 3
  • 19
  • 39
  • It looks like this issue might relate to you're situation https://github.com/deployphp/deployer/issues/2676 It looks like there used to be a way to get the branch option set on the host that is no longer working in 7.0 – drew010 Feb 27 '22 at 16:50

1 Answers1

1

You can set the branch with ->set('branch', 'master') in your host configuration.

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

host('production')
  ->set('branch', 'master')
Sven K.
  • 31
  • 2