|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Deployer; |
| 4 | + |
| 5 | +require_once __DIR__ . '/common.php'; |
| 6 | + |
| 7 | +require_once __DIR__ . '/../contrib/clearserverpaths.php'; |
| 8 | +require_once __DIR__ . '/../contrib/filetransfer.php'; |
| 9 | +require_once __DIR__ . '/../contrib/hardening.php'; |
| 10 | +require_once __DIR__ . '/../contrib/mysql.php'; |
| 11 | +require_once __DIR__ . '/../contrib/wordpresscli.php'; |
| 12 | + |
| 13 | +add('recipes', ['cloudpanel']); |
| 14 | + |
| 15 | +/** |
| 16 | + * Siteground configuration |
| 17 | + */ |
| 18 | +set('shared_dirs', ['wp-content/uploads']); |
| 19 | +set('writable_dirs', ['wp-content/uploads']); |
| 20 | + |
| 21 | +/* ----------------- filesharden ----------------- */ |
| 22 | +// for task 'deploy:harden' |
| 23 | +set('harden_dir_permissions', 'u=rx,g=rx,o=rx'); |
| 24 | +set('harden_file_permissions', 'u=r,g=r,o=r'); |
| 25 | +/* ----------------- clear_server_paths ----------------- */ |
| 26 | +set('clear_server_paths', []); |
| 27 | + |
| 28 | +/** |
| 29 | + * Deploy task |
| 30 | + */ |
| 31 | +// desc('Prepares a new release'); |
| 32 | +// task('deploy:prepare', [ |
| 33 | +// 'deploy:info', |
| 34 | +// 'deploy:setup', |
| 35 | +// 'deploy:lock', |
| 36 | +// 'deploy:release', |
| 37 | +// 'deploy:update_code', |
| 38 | +// 'deploy:shared', |
| 39 | +// 'deploy:writable', |
| 40 | +// ]); |
| 41 | + |
| 42 | +// desc('Publishes the release'); |
| 43 | +// task('deploy:publish', [ |
| 44 | +// 'deploy:symlink', |
| 45 | +// 'deploy:unlock', |
| 46 | +// 'deploy:cleanup', |
| 47 | +// 'deploy:success', |
| 48 | +// ]); |
| 49 | + |
| 50 | +task('deploy', [ |
| 51 | + 'deploy:prepare', |
| 52 | + 'deploy:vendors', |
| 53 | + 'deploy:clear_paths', |
| 54 | + 'deploy:harden', |
| 55 | + 'deploy:publish', |
| 56 | + 'cp:purge' |
| 57 | +])->desc('Deploys your project'); |
| 58 | + |
| 59 | +/** |
| 60 | + * Hooks |
| 61 | + */ |
| 62 | +before('deploy:cleanup', function () { |
| 63 | + invoke('deploy:unharden'); |
| 64 | +})->desc('Unharden previous site releases'); |
| 65 | + |
| 66 | +after('deploy:harden', function () { |
| 67 | + invoke('deploy:writablehardened'); |
| 68 | +})->desc('Apply writable permissions to files/folders in harden_writable_files'); |
| 69 | + |
| 70 | +after('deploy:failed', function () { |
| 71 | + invoke('deploy:unlock'); |
| 72 | + invoke('deploy:unharden'); |
| 73 | +})->desc('Unlock after deploy:failed and unharded failed release'); |
| 74 | +after('deploy:symlink', 'deploy:clear_server_paths'); |
| 75 | + |
| 76 | +task('pull-all', [ |
| 77 | + 'db:pull-replace', |
| 78 | + 'files:pull', |
| 79 | +])->desc('Pull db from a remote stage, replaces instances of domain in db, and pulls writable files'); |
| 80 | + |
| 81 | +// task('cp', function () { |
| 82 | +// $wpcli = new WordpressCli(currentHost()); |
| 83 | +// $command = $wpcli->command('cp'); |
| 84 | +// run($command, ['real_time_output' => true]); |
| 85 | +// })->desc('Show the siteground cli options'); |
| 86 | + |
| 87 | +task('cp:purge:transient', function () { |
| 88 | + $wpcli = new WordpressCli(currentHost()); |
| 89 | + $command = $wpcli->command('transient delete --all'); |
| 90 | + run($command); |
| 91 | +})->desc('Purge wp transients'); |
| 92 | + |
| 93 | +task('cp:purge', function () { |
| 94 | + invoke('cp:purge:transient'); |
| 95 | + invoke('wp:cache:flush'); |
| 96 | + // invoke('sg:purge:memcached'); |
| 97 | + // invoke('sg:purge:dynamic'); |
| 98 | +})->desc('Purge the transients, wp cache, and Siteground dynamic and memcached caches'); |
| 99 | + |
| 100 | +// task('sg:purge:dynamic', function () { |
| 101 | +// $wpcli = new WordpressCli(currentHost()); |
| 102 | +// $command = $wpcli->command('sg purge'); |
| 103 | +// run($command); |
| 104 | +// })->desc('Purge the Siteground dynamic cache'); |
| 105 | + |
| 106 | +// task('sg:purge:memcached', function () { |
| 107 | +// $wpcli = new WordpressCli(currentHost()); |
| 108 | +// $command = $wpcli->command('sg purge memcached'); |
| 109 | +// run($command); |
| 110 | +// })->desc('Purge the Siteground memcached cache'); |
0 commit comments