-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.php
101 lines (89 loc) · 2.36 KB
/
deploy.php
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
namespace Deployer;
require 'recipe/common.php';
require 'contrib/rsync.php';
// Config
set('repository', 'https://jsnmrs@github.com/jsnmrs/aggro.git');
set('writable_mode', 'chmod');
set('keep_releases', 3);
add('shared_dirs', ['public/thumbs', 'writable/cache', 'writable/logs']);
add('writable_dirs', ['writable/cache', 'writable/logs']);
// Hosts
host('bmxfeed.com')
->set('labels', ['stage' => 'prod'])
->setHostname('bmxfeed.com')
->setRemoteUser('bmxfeed')
->setDeployPath('/home/bmxfeed/aggro');
host('dev.bmxfeed.com')
->set('labels', ['stage' => 'dev'])
->setHostname('dev.bmxfeed.com')
->setRemoteUser('bmxfeed')
->setDeployPath('/home/bmxfeed/aggro-dev');
if (file_exists('/var/www/.ssh/config')) {
host('bmxfeed.com')->setConfigFile('/var/www/.ssh/config');
}
// rsync from local.
set('rsync_src', static fn () => __DIR__);
add('rsync', [
'exclude' => [
'.browserslistrc',
'.docksal',
'.editorconfig',
'.env*',
'.git',
'.github',
'.gitignore',
'*.sql',
'.ssh',
'.stylelintrc',
'build',
'composer.json',
'composer.lock',
'deploy.php',
'deploy.sh',
'*DS_Store',
'LICENSE',
'node_modules',
'package.json',
'package-lock.json',
'phpcs.xml',
'phpmd.xml',
'phpunit.xml.dist',
'postcss.config.js',
'public/thumbs',
'README.md',
'tests',
'vendor/bin',
'writable/cache',
'writable/debugbar',
'writable/logs',
],
]);
// Move .env file (from disk or action)
task('deploy:secrets', static function () {
if (getenv('DOT_ENV')) {
file_put_contents(__DIR__ . '/.env-production', getenv('DOT_ENV'));
}
if (file_exists('.env-production')) {
upload('.env-production', get('release_or_current_path') . '/.env');
}
});
// Copy crontab settings from repo.
task('deploy:cron', static function () {
run('cd ~/');
run('crontab ' . get('release_or_current_path') . '/.crontab');
run('crontab -l');
});
desc('Deploy the application');
task('deploy', [
'deploy:info',
'deploy:prepare',
'rsync',
'deploy:shared',
'deploy:writable',
'deploy:secrets',
'deploy:symlink',
'deploy:cron',
'deploy:unlock',
]);
after('deploy:failed', 'deploy:unlock');