-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidxfile.php
More file actions
46 lines (36 loc) · 1.18 KB
/
idxfile.php
File metadata and controls
46 lines (36 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use Idephix\Idephix;
$targets = array(
'stage' => array(
'hosts' => array('10.250.2.44'),
'ssh_params' => ['user' => 'cocoon'],
'deploy' => array(
'local_base_dir' => '.',
'remote_base_dir' => "/var/www/vhosts/getwelo/",
'rsync_exclude_file' => 'deploy_exclude'
),
),
);
$idx = new Idephix($targets);
$deploy = function($go = false) use ($idx)
{
$target = $idx->getCurrentTarget();
if ($target === null) {
throw new \InvalidArgumentException(
"Please provide a valid target with --env=<target>"
);
}
$host = $idx->getCurrentTargetHost();
$user = $target->get('ssh_params.user');
$localpath = $target->get('deploy.local_base_dir');
$path = $target->get('deploy.remote_base_dir');
$opts = '-rlDcz --no-perms --force --delete --progress';
$opts .= ' --exclude-from=' . $target->get('deploy.rsync_exclude_file');
$dryrun = $go ? '' : '--dry-run';
$idx->local("rsync $opts $dryrun -e 'ssh' $localpath $user@$host:$path");
if ($go) {
$idx->remote("cd $path && composer install --no-dev -o");
}
};
$idx->add('deploy', $deploy);
$idx->run();