Deployer full (ok)

https://deployer.org/docs/7.x/getting-started

1. Ví dụ đã làm trên Ubuntu

/home/lionel/deployer/composer.json

{
    "require-dev": {
        "deployer/deployer": "^7.0"
    }
}

/home/lionel/deployer/deploy.php

<?php
namespace Deployer;
require 'recipe/wordpress.php';
// Config
set('repository', 'https://github.com/phamngoctuong/wordpressgitserver.git');
add('shared_files', []);
add('shared_dirs', []);
add('writable_dirs', []);
// Hosts
host('localhost')
    ->set('remote_user', 'lionel')
    ->set('deploy_path', '/var/www/test123');
// Desc
desc('Instructs the master supervisor to continue processing jobs');
// Hooks
after('deploy:failed', 'deploy:unlock');

2. Ví dụ đã lầm trên server

Bước 1 ✔️: Đăng nhập server bằng ssh
ssh hotfactory@10.200.102.133
Pass: cmshf2022

C:\Users\Administrator\AppData\Local\Temp\scp10183\home\hotfactory\deploy.php

<?php
namespace Deployer;

require 'recipe/laravel.php';
//require 'contrib/slack.php';

// Config

// Project name
set('application','marinesTeam26CMS');

// Project repository
set('repository','https://github.com/phamngoctuong/uploadfile.git');

// [Optional] Allocate tty for git clone. Default value is false.
//set('git_tty', true);

set('keep_releases', 5);

set('dep_env', 'staging');

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

// Hosts

host('localhost')
  ->set('remote_user', 'hotfactory')
  ->set('deploy_path', '/var/www/site');

// Hooks
// Tasks
task('set_branch', function(){
  $branch = null;
  $stage = get('dep_env');
  if ($stage == 'production') {
    $branch = 'main';
  } else if ($stage == 'staging') {
    $branch = input()->getOption('branch');
    if (empty($branch)) {
      $branch = 'stg';
    }
  }
  set('branch', $branch);
});
before('deploy', 'set_branch');

after('deploy:failed', 'deploy:unlock');

// slack
//set('slack_webhook', 'https://hooks.slack.com/services/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');
//after('set_branch', 'slack:notify');
//after('deploy:success', 'slack:notify:success');
//after('deploy:failed', 'slack:notify:failure');
//after('rollback', 'slack:notify:rollback');

// nginx,php再起動
after('deploy:success', 'nginx_reload');
task('nginx_reload', function () {
  run('sudo systemctl reload php81-php-fpm');
  run('sudo systemctl reload nginx');
});

Chạy lệnh sau:

dep deploy.php --branch=main

Cai dat tren local windows

composer global require deployer/deployer

https://stackoverflow.com/questions/39805060/how-to-install-and-run-deployer-on-windows

Last updated