-
Notifications
You must be signed in to change notification settings - Fork 0
set WP_HOME for environment #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| desc('Setup initial deploy'); | ||
| task('setup', [ | ||
| 'wordpress:set-wp-home', | ||
| 'scaffold:env', | ||
| ]); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,19 @@ | |
| run('curl {{ url }}/kinsta-clear-cache-all/'); | ||
| }); | ||
|
|
||
| task('wordpress:set-wp-home', function () { | ||
| // add WP_HOME to environment file | ||
| $file = realpath($_SERVER['DOCUMENT_ROOT']) . '/config/environments/' . currentHost()->getAlias() . '.php'; | ||
| $lines = file($file); | ||
| $newLines = []; | ||
| foreach ($lines as $line) { | ||
| if (strpos($line, "Config::define('WP_HOME'") === false) { | ||
| $newLines[] = $line; | ||
| } | ||
| } | ||
| $newLines[] = 'Config::define(\'WP_HOME\', \'' . get('url', 'https://') . '\');'; | ||
| file_put_contents($file, implode('', $newLines)); | ||
| }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn’t this run on the remote host? it needs to run locally so you can commit it to git (or else a deploy would wipe the change).
you can use note that no production.php config exists on sites currently, you should check it exists and is writable: |
||
|
|
||
| task('scaffold:env', function () { | ||
| if (test('[ -f {{deploy_path}}/shared/.env ]')) { | ||
|
|
@@ -53,8 +66,6 @@ | |
| $dbName = ask('DB_NAME', get('scaffold_machine_name', '')); | ||
| $dbUser = ask('DB_USER', get('scaffold_machine_name', '')); | ||
| $dbPassword = askHiddenResponse('DB_PASSWORD'); | ||
| $wpEnv = ask('WP_ENV', currentHost()->getAlias()); | ||
| $wpHome = ask('WP_HOME', $url); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep these but default them to empty? And only add them if user has set them. |
||
| $domainCurrentSite = ask('DOMAIN_CURRENT_SITE', parse_url($url, PHP_URL_HOST)); | ||
|
|
||
| run('mkdir -p {{deploy_path}}/shared'); | ||
|
|
@@ -63,8 +74,6 @@ | |
| run('sed -i "/^DB_NAME=/c\\DB_NAME=' . $dbName . '" {{deploy_path}}/shared/.env'); | ||
| run('sed -i "/^DB_USER=/c\\DB_USER=' . $dbUser . '" {{deploy_path}}/shared/.env'); | ||
| run('sed -i "/^DB_PASSWORD=/c\\DB_PASSWORD=\'' . $dbPassword . '\'" {{deploy_path}}/shared/.env'); | ||
| run('sed -i "/^WP_ENV=/c\\WP_ENV=' . $wpEnv . '" {{deploy_path}}/shared/.env'); | ||
| run('sed -i "/^WP_HOME=/c\\WP_HOME=' . $wpHome . '" {{deploy_path}}/shared/.env'); | ||
| run('sed -i "/^DOMAIN_CURRENT_SITE=/c\\DOMAIN_CURRENT_SITE=' . $domainCurrentSite . '" {{deploy_path}}/shared/.env'); | ||
|
|
||
| foreach (['AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT'] as $key) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is quite difficult to read because of the escaping. compare to eg.