-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy.php
More file actions
100 lines (86 loc) · 2.38 KB
/
deploy.php
File metadata and controls
100 lines (86 loc) · 2.38 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
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
<?php
namespace Deployer;
require 'recipe/common.php';
set( 'application', 'wptest' );
set( 'repository', 'git@github.com:mklasen/_repo_.git' );
// [Optional] Allocate tty for git clone. Default value is false.
set( 'git_tty', true );
// Shared files/dirs between deploys
set( 'shared_files', array() );
set( 'shared_dirs', array() );
set( 'writable_dirs', array() );
set( 'composer_options', 'install --optimize-autoloader' );
host( 'prod' )
->stage( 'prod' )
->set( 'branch', 'master' )
->hostname( 'bijnoabers' )
->set( 'deploy_path', '/home/master/sites/__site__/deploy' )
->set( 'keep_releases', 5 );
// Symlinks
task(
'deploy:wp_symlinks',
function () {
writeln( ' - Symlink media directories' );
run( 'ln -nfs {{deploy_path}}/shared/uploads {{release_path}}/app/www/content/uploads' );
writeln( ' - Copy wp-config.php' );
run( '[ -f {{deploy_path}}/shared/wp-config.php ] && cp {{deploy_path}}/shared/wp-config.php {{release_path}}/app/www/wp-config.php || cp {{release_path}}/app/www/wp-config.php {{deploy_path}}/shared/wp-config.php' );
writeln( ' - Environment symlink' );
run( 'ln -nfs {{deploy_path}}/shared/.env {{release_path}}/.env' );
writeln( ' - htaccess symlink' );
run( 'ln -nfs {{deploy_path}}/shared/.htaccess {{release_path}}/app/www/.htaccess' );
}
);
// Robots.txt - we want this on all environments except for production
task(
'deploy:robots_txt',
function () {
$stage = null;
if ( input()->hasArgument( 'stage' ) ) {
$stage = input()->getArgument( 'stage' );
}
if ( 'prod' === $stage ) {
$robots_txt = '';
} else {
$robots_txt = implode(
"\n",
array(
'# This is a staging site. Do not index.',
'User-agent: *',
'Disallow: /',
)
);
}
writeln( 'Uploading robots.txt' );
run( "echo '$robots_txt ' > {{release_path}}/app/www/robots.txt" );
}
);
task(
'deploy:clear_cache',
function() {
// run( "touch ~/wordpress/php-fpm.service" );
}
);
// Tasks that run on deployment
task(
'deploy',
array(
'deploy:info',
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:writable',
'deploy:vendors',
'deploy:wp_symlinks',
'deploy:robots_txt',
'deploy:clear_paths',
'deploy:symlink',
'deploy:clear_cache',
'deploy:unlock',
'cleanup',
'success',
)
);
// [Optional] If deploy fails automatically unlock.
after( 'deploy:failed', 'deploy:unlock' );