-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy
executable file
·60 lines (44 loc) · 1.65 KB
/
deploy
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env php
<?php
use Codedeployer\Deploy;
use Composer\Autoload\ClassLoader;
$file = __DIR__ . '/../../../autoload.php';
if (file_exists($file)) {
define('CODEDEPLOYER_COMPOSER_INSTALL', $file);
}
if (!defined('CODEDEPLOYER_COMPOSER_INSTALL')) {
fwrite(STDERR, 'You need to set up the project dependencies using Composer');
die(1);
}
require CODEDEPLOYER_COMPOSER_INSTALL;
$reflection = new \ReflectionClass(ClassLoader::class);
$rootDir = dirname($reflection->getFileName(), 3);
if (isset($argv[1]) && $argv[1] == '--setup') {
$packageDir = dirname(__DIR__, 1);
$deployDir = $rootDir . '/deploy/';
if (!is_dir($deployDir)) {
mkdir($deployDir);
}
// Copy all files contained in the config directory to the project deploy directory
// Don't overwrite rsync_exclude if it exists
exec("rsync -a --exclude 'hook-scripts/rsync_exclude' --exclude 'config.php' {$packageDir}/config/ {$deployDir}");
if (!file_exists("{$deployDir}/hook-scripts/rsync_exclude")) {
exec("cp -a {$packageDir}/config/hook-scripts/rsync_exclude* {$deployDir}/hook-scripts/");
} else {
echo "rsync_exclude file already present, skipping\n";
}
// Don't overwrite config.php if it exists
if (!file_exists("{$deployDir}/config.php")) {
exec("cp -a {$packageDir}/config/config.php* {$deployDir}/");
} else {
echo "config.php file already present, skipping\n";
}
echo "Config files successfully installed\n";
exit(0);
}
$deploymentGroups = [];
if (isset($argv[1])) {
$deploymentGroups = explode(',', $argv[1]);
}
$deployer = new Deploy();
$deployer->run($rootDir, $deploymentGroups);