mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 00:32:25 +01:00
Drupal 7 recipe
This commit is contained in:
parent
988b137c6c
commit
f0906e600d
92
recipe/drupal7.php
Normal file
92
recipe/drupal7.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/* (c) Sergio Carracedo <info@sergiocarraedo.es>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/common.php';
|
||||
|
||||
task('deploy', [
|
||||
'deploy:prepare',
|
||||
'deploy:release',
|
||||
'deploy:update_code',
|
||||
'deploy:shared',
|
||||
'deploy:symlink',
|
||||
'cleanup'
|
||||
]);
|
||||
|
||||
//Set drupal site. Change if you use different site
|
||||
env('drupal_site', 'default');
|
||||
|
||||
|
||||
//Drupal 7 shared dirs
|
||||
set('shared_dirs', [
|
||||
'sites/{{drupal_site}}/files',
|
||||
]);
|
||||
|
||||
//Drupal 7 sharef files
|
||||
set('shared_files', [
|
||||
'sites/{{drupal_site}}/settings.php',
|
||||
]);
|
||||
|
||||
//Drupal 7 Writable dirs
|
||||
set('writable_dirs', [
|
||||
'sites/{{drupal_site}}/files',
|
||||
]);
|
||||
|
||||
|
||||
//Create and upload Drupal 7 settings.php using values from secrets
|
||||
task('drupal:settings', function () {
|
||||
if (askConfirmation('Are you sure to generate and upload settings.php file?')) {
|
||||
$basepath = dirname(__FILE__). '/drupal7';
|
||||
|
||||
//Import secrets
|
||||
require_once $basepath . '/spyc.php';
|
||||
$secrets = Spyc::YAMLLoad( $basepath . '/secrets.yml' );
|
||||
|
||||
//Prepare replacement variables
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveArrayIterator($secrets)
|
||||
);
|
||||
|
||||
$replacements = [];
|
||||
foreach($iterator as $key => $value) {
|
||||
$keys = [];
|
||||
for ($i = $iterator->getDepth(); $i > 0; $i --) {
|
||||
$keys[] = $iterator->getSubIterator($i - 1)->key();
|
||||
}
|
||||
$keys[] = $key;
|
||||
|
||||
$replacements['{{' . implode('.', $keys) . '}}'] = $value;
|
||||
}
|
||||
|
||||
//Create settings from template
|
||||
$settings = file_get_contents( $basepath . '/settings.php');
|
||||
|
||||
$settings = strtr($settings, $replacements);
|
||||
|
||||
writeln('settings.php created succesfuly');
|
||||
|
||||
$tmpFilename = tempnam( $basepath , 'tmp_settings_' );
|
||||
file_put_contents($tmpFilename, $settings);
|
||||
|
||||
uploadEnv($tmpFilename, '{{deploy_path}}/shared/sites/{{drupal_site}}/settings.php');
|
||||
|
||||
unlink($tmpFilename);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//Upload Drupal 7 files folder
|
||||
task('drupal:upload_files', function () {
|
||||
if (askConfirmation('Are you sure?')) {
|
||||
uploadEnv('sites/{{drupal_site}}/files', '{{deploy_path}}/shared/sites/{{drupal_site}}/files');
|
||||
}
|
||||
});
|
||||
|
||||
function uploadEnv($local, $remote) {
|
||||
$local = env()->parse($local);
|
||||
$remote = env()->parse($remote);
|
||||
upload($local, $remote);
|
||||
}
|
8
recipe/drupal7/secrets.yml
Normal file
8
recipe/drupal7/secrets.yml
Normal file
@ -0,0 +1,8 @@
|
||||
database:
|
||||
name: database name
|
||||
host: localhost
|
||||
user: database user
|
||||
pass: database pass
|
||||
port:
|
||||
driver: mysql
|
||||
prefix:
|
1147
recipe/drupal7/spyc.php
Normal file
1147
recipe/drupal7/spyc.php
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user