<?php
declare(strict_types=1);
namespace Deployer;
// Include base recipes
require 'recipe/common.php';
require 'contrib/cachetool.php';
require 'contrib/rsync.php';
// Include hosts
import('.hosts.yml');
set('http_user', 'u000000');
set('http_group', 'ftpusers');
set('/usr/bin/php8.3-cli', 'php');
set('bin/typo3', '{{release_path}}/vendor/bin/typo3');
// Set maximum number of releases
set('keep_releases', 5);
// Set TYPO3 docroot
set('typo3_webroot', 'public');
// Set shared directories
$sharedDirectories = [
'{{typo3_webroot}}/fileadmin',
'{{typo3_webroot}}/typo3temp',
];
set('shared_dirs', $sharedDirectories);
// Set shared files
$sharedFiles = [
'{{typo3_webroot}}/.htaccess',
'config/system/additional.php',
];
set('shared_files', $sharedFiles);
// Define all rsync excludes
$exclude = [
// OS specific files
'.DS_Store',
'Thumbs.db',
// Project specific files and directories
'.ddev',
'.editorconfig',
'.fleet',
'.git*',
'.idea',
'.php-cs-fixer.dist.php',
'.vscode',
'auth.json',
'deploy.php',
'.hosts.yml',
'gitlab-ci.yml',
'phpstan.neon',
'phpunit.xml',
'README*',
'rector.php',
'typoscript-lint.yml',
'/.deployment',
'/var',
'/**/Tests/*',
];
// Define rsync options
set('rsync', [
'exclude' => array_merge($sharedDirectories, $sharedFiles, $exclude),
'exclude-file' => false,
'include' => [],
'include-file' => false,
'filter' => [],
'filter-file' => false,
'filter-perdir' => false,
'flags' => 'az',
'options' => ['delete'],
'timeout' => 300,
]);
set('rsync_src', './');
// Use rsync to update code during deployment
task('deploy:update_code', function () {
invoke('rsync:warmup');
invoke('rsync');
});
// TYPO3 tasks
desc('Flush all caches');
task('typo3:cache_flush', function () {
run('{{bin/typo3}} cache:flush');
});
desc('Warm up caches');
task('typo3:cache_warmup', function () {
run('{{bin/typo3}} cache:warmup');
});
desc('Set up all installed extensions');
task('typo3:extension_setup', function () {
run('{{bin/typo3}} extension:setup');
});
desc('Fix folder structure');
task('typo3:fix_folder_structure', function () {
run('{{bin/typo3}} install:fixfolderstructure');
});
desc('Update language files');
task('typo3:language_update', function () {
run('{{bin/typo3}} language:update');
});
desc('Update databse schema');
task('typo3:update_database', function () {
run("{{bin/typo3}} database:updateschema '*.add,*.change'");
});
desc('Update reference index');
task('typo3:update_reference_index', function () {
run("{{bin/typo3}} referenceindex:update");
});
desc('Execute upgrade wizards');
task('typo3:upgrade_all', function () {
run('{{bin/typo3}} upgrade:prepare');
run('{{bin/typo3}} upgrade:run all --confirm all');
});
// add own settings
desc('backend lock');
task('typo3:backend_lock', function () {
run("{{bin/typo3}} backend:lock");
});
desc('backend unlock');
task('typo3:backend_unlock', function () {
run("{{bin/typo3}} backend:unlock");
});
desc('cleanup deletedrecords');
task('typo3:cleanup_deletedrecords', function () {
run("{{bin/typo3}} cleanup:deletedrecords");
});
desc('redirects checkintegrity');
task('typo3:redirect_checkintegrity', function () {
run("{{bin/typo3}} redirects:checkintegrity");
});
desc('redirects cleanup');
task('typo3:redirect_cleanup', function () {
run("{{bin/typo3}} redirects:cleanup");
});
desc('referenceindex update');
task('typo3:referenceindex_update', function () {
run("{{bin/typo3}} referenceindex:update");
});
// Hoster spezifisch!
des('correct permissions');
task('correct_permissions', function () {
run('find {{relase_path}} -type d -not -path "{{release_path}}/vendor/bin*" -print0 | xargs -0 chmod 0755');
run('find {{relase_path}} -type f -not -path "{{release_path}}/vendor/bin*" -print0 | xargs -0 chmod 0644');
});
// Register TYPO3 tasks
// bevor der Symlink umgeschaltet wird
before('deploy:symlink', function () {
invoke('typo3:backend_lock');
invoke('correct_permissions');
invoke('typo3:fix_folder_structure');
invoke('typo3:extension_setup');
invoke('typo3:update_database');
invoke('typo3:update_reference_index');
invoke('typo3:language_update');
//invoke('typo3:upgrade_all');
});
// nachdem der Symlink umgeschaltet wurde
after('deploy:symlink', function () {
invoke('typo3:cache_flush');
invoke('typo3:cache_warmup');
invoke('typo3:backend_unlock');
});
// Main deployment task
desc('Deploy TYPO3 SPRACHspatz');
task('deploy', [
'deploy:prepare',
'deploy:publish',
]);
// Unlock on failed deployment
after('deploy:failed', 'deploy:unlock');