OXID-Deployer-Project/deploy.php

49 regels
1.6 KiB
PHP

<?php
namespace Deployer;
require 'recipe/composer.php';
// Setup
import(__DIR__. '/inventory.yml');
// Hooks
after('deploy:failed', 'deploy:unlock');
2024-10-16 16:11:48 +02:00
after('deploy:vendors', 'deploy:d3OxidTasks');
/// Tasks
desc('Oxid related tasks');
task('deploy:d3OxidTasks', [
'deploy:clear_paths',
2024-10-16 23:22:22 +02:00
'deploy:setShopsOffline',
'deploy:setShopsOnline'
2024-10-16 16:11:48 +02:00
]);
2024-10-16 23:22:22 +02:00
desc('set shops offline');
task('deploy:setShopsOffline', function() {
if (has('bin/mysql') && strlen(get('bin/mysql')) &&
2024-10-17 08:50:46 +02:00
has('db_name') && strlen(get('db_name')) &&
has('db_conf_path') && strlen(get('db_conf_path')) && test("[ -f {{db_conf_path}} ]")
2024-10-16 23:22:22 +02:00
) {
$query = "UPDATE oxshops SET oxactive = '0', OXREGISTERSUBJECT = CONCAT('..', OXREGISTERSUBJECT) WHERE oxactive = '1';";
2024-10-17 08:50:46 +02:00
run('{{bin/mysql}} --defaults-extra-file={{db_conf_path}} {{db_name}} -e "'.$query.'"');
2024-10-16 23:22:22 +02:00
} else {
info('missing config, task skipped');
}
})->select('role=production,role=stage');
desc('set shops online');
task('deploy:setShopsOnline', function() {
if (has('bin/mysql') && strlen(get('bin/mysql')) &&
2024-10-17 08:50:46 +02:00
has('db_name') && strlen(get('db_name')) &&
has('db_conf_path') && strlen(get('db_conf_path')) && test("[ -f {{db_conf_path}} ]")
2024-10-16 23:22:22 +02:00
) {
$query = "UPDATE oxshops SET oxactive = '1', OXREGISTERSUBJECT = SUBSTR(OXREGISTERSUBJECT, 3) WHERE oxactive = '0' AND OXREGISTERSUBJECT LIKE '..%';";
2024-10-17 08:50:46 +02:00
run('{{bin/mysql}} --defaults-extra-file={{db_conf_path}} {{db_name}} -e "'.$query.'"');
2024-10-16 23:22:22 +02:00
} else {
info('missing config, task skipped');
}
})->select('role=production,role=stage');