Created
January 13, 2025 10:13
-
-
Save wowaTYPO3/065963d5e8deb6d0da410de337b09f5c to your computer and use it in GitHub Desktop.
deploy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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', 'USERNAME'); | |
set('http_group', 'USERGROUP'); | |
set('/usr/local/bin/php', '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/*', | |
'dbv13.sql', | |
'fileadmin.tar.gz', | |
'README.md', | |
'fetchdatabase.sh', | |
'renovate.json' | |
]; | |
// 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 database 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'); | |
}); | |
task('correct_permissions', function () { | |
run('find {{release_path}} -type d -not -path "{{release_path}}/vendor/bin*" -print0 | xargs -0 chmod 0755'); | |
run('find {{release_path}} -type f -not -path "{{release_path}}/vendor/bin*" -print0 | xargs -0 chmod 0644'); | |
}); | |
// Register TYPO3 tasks | |
before('deploy:symlink', function () { | |
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'); | |
}); | |
after('deploy:symlink', function () { | |
invoke('typo3:cache_flush'); | |
invoke('typo3:cache_warmup'); | |
}); | |
// Main deployment task | |
desc('Deploy TYPO3 project'); | |
task('deploy', [ | |
'deploy:prepare', | |
'deploy:publish', | |
]); | |
// Unlock on failed deployment | |
after('deploy:failed', 'deploy:unlock'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment