2016-06-27 04:25:23 +12:00
|
|
|
<?php
|
2016-11-17 13:26:01 +13:00
|
|
|
namespace Deployer;
|
|
|
|
|
2016-06-27 04:25:23 +12:00
|
|
|
require_once __DIR__ . '/common.php';
|
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
add('recipes', ['silverstripe']);
|
|
|
|
|
2016-06-27 04:25:23 +12:00
|
|
|
/**
|
|
|
|
* Silverstripe configuration
|
|
|
|
*/
|
|
|
|
|
2019-10-21 18:58:24 +13:00
|
|
|
set('shared_assets', function () {
|
2021-04-03 13:05:45 +01:00
|
|
|
if (test('[ -d {{release_or_current_path}}/public ]') || test('[ -d {{deploy_path}}/shared/public ]')) {
|
2020-01-29 00:13:11 -08:00
|
|
|
return 'public/assets';
|
2019-10-21 18:58:24 +13:00
|
|
|
}
|
2020-01-29 00:13:11 -08:00
|
|
|
return 'assets';
|
2019-10-21 18:58:24 +13:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-06-27 04:25:23 +12:00
|
|
|
// Silverstripe shared dirs
|
|
|
|
set('shared_dirs', [
|
2019-10-21 18:58:24 +13:00
|
|
|
'{{shared_assets}}'
|
2016-06-27 04:25:23 +12:00
|
|
|
]);
|
|
|
|
|
|
|
|
// Silverstripe writable dirs
|
2019-10-21 18:58:24 +13:00
|
|
|
set('writable_dirs', [
|
|
|
|
'{{shared_assets}}'
|
|
|
|
]);
|
2016-06-27 04:25:23 +12:00
|
|
|
|
2018-01-11 17:47:05 +13:00
|
|
|
// Silverstripe cli script
|
|
|
|
set('silverstripe_cli_script', function () {
|
|
|
|
$paths = [
|
|
|
|
'framework/cli-script.php',
|
|
|
|
'vendor/silverstripe/framework/cli-script.php'
|
|
|
|
];
|
|
|
|
foreach ($paths as $path) {
|
2021-04-03 13:05:45 +01:00
|
|
|
if (test('[ -f {{release_or_current_path}}/'.$path.' ]')) {
|
2018-01-11 17:47:05 +13:00
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-06-27 04:25:23 +12:00
|
|
|
/**
|
|
|
|
* Helper tasks
|
|
|
|
*/
|
2021-11-08 22:59:39 +01:00
|
|
|
desc('Runs /dev/build');
|
2016-06-27 04:25:23 +12:00
|
|
|
task('silverstripe:build', function () {
|
2022-02-24 17:54:56 +01:00
|
|
|
run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build');
|
2020-10-29 23:16:36 +01:00
|
|
|
});
|
2016-06-27 04:25:23 +12:00
|
|
|
|
2021-11-08 22:59:39 +01:00
|
|
|
desc('Runs /dev/build?flush=all');
|
2016-06-27 04:25:23 +12:00
|
|
|
task('silverstripe:buildflush', function () {
|
2022-02-24 17:54:56 +01:00
|
|
|
run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build flush=all');
|
2020-10-29 23:16:36 +01:00
|
|
|
});
|
2016-06-27 04:25:23 +12:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Main task
|
|
|
|
*/
|
2021-11-08 22:59:39 +01:00
|
|
|
desc('Deploys your project');
|
2016-06-27 04:25:23 +12:00
|
|
|
task('deploy', [
|
2020-10-08 01:53:45 +02:00
|
|
|
'deploy:prepare',
|
2016-06-27 04:25:23 +12:00
|
|
|
'deploy:vendors',
|
|
|
|
'silverstripe:buildflush',
|
2020-10-08 01:53:45 +02:00
|
|
|
'deploy:publish',
|
2020-10-29 23:16:36 +01:00
|
|
|
]);
|