Skip to content

Commit ca546e9

Browse files
grapplerocean90
andauthored
Add task to check if WordPress is installed otherwise install (#30)
Co-authored-by: Dominik Schilling <dominikschilling+git@gmail.com>
1 parent f288e34 commit ca546e9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

res/deploy.tpl.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,34 @@ function () {
3434
inventory( 'deploy.yml' );
3535

3636
// Tasks.
37+
desc( 'Check WordPress is installed' );
38+
task(
39+
'wp:install',
40+
function (): void {
41+
if ( ! get( 'wordpress' ) ) {
42+
return;
43+
}
44+
45+
within(
46+
'{{release_path}}',
47+
function (): void {
48+
$is_installed = test( '{{bin/wp}} core is-installed' );
49+
if ( $is_installed ) {
50+
return;
51+
}
52+
writeln( '<comment>Installing WordPress</comment>' );
53+
$env = run( 'set -o allexport; source wordpress/.env; set +o allexport; echo "https://$_HTTP_HOST,$MULTISITE"' );
54+
[ $url, $is_multisite ] = explode( ',', $env );
55+
if ( $is_multisite ) {
56+
run( "{{bin/wp}} core multisite-install --url={$url} --title=WordPress --admin_user=required --admin_email=info@required.ch --skip-email --skip-config" );
57+
} else {
58+
run( "{{bin/wp}} core install --url={$url} --title=WordPress --admin_user=required --admin_email=info@required.ch --skip-email" );
59+
}
60+
}
61+
);
62+
}
63+
);
64+
3765
desc( 'Install WordPress translations' );
3866
task(
3967
'wp:install_translations',
@@ -133,6 +161,7 @@ function (): void {
133161
'deploy:shared',
134162
'deploy:writable',
135163
'deploy:vendors',
164+
'wp:install',
136165
'wp:translations',
137166
'deploy:clear_paths',
138167
'deploy:symlink',

0 commit comments

Comments
 (0)