From 178a5e6c14a10f3bf5efdb6f7977f948d1ffc9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Wed, 21 Oct 2026 18:52:41 +0200 Subject: [PATCH] feat: first deploy sets up the shared paths and the secrets template typo3:secrets:init uploads secrets.example.php into shared/ when no secrets.php exists (never overwrites one); typo3:secrets:check stops the deploy before extension:setup while the database connection is still missing. So the first "dep deploy prod" creates the structure and stops before anything goes live. Co-Authored-By: Claude Opus 5.5 --- deploy.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/deploy.php b/deploy.php index d2ec180..3ea1937 100644 --- a/deploy.php +++ b/deploy.php @@ -112,6 +112,27 @@ task('host:check', function () { } }); +desc('Put the secrets.php template into shared/ unless a secrets.php is there already (never overwrites)'); +task('typo3:secrets:init', function () { + $target = '{{deploy_path}}/shared/config/system/secrets.php'; + if (test("[ -s $target ]")) { + return; + } + run('mkdir -p {{deploy_path}}/shared/config/system'); + upload(__DIR__ . '/config/system/secrets.example.php', $target); + run("chmod 600 $target"); + writeln('Created ' . parse($target) . ' from the template: fill it in, then deploy again.'); +}); + +desc('Stop before the database is touched while secrets.php still lacks the database connection'); +task('typo3:secrets:check', function () { + $secrets = '{{deploy_path}}/shared/config/system/secrets.php'; + $filled = run("{{bin/php}} -r '\$s = require \"$secrets\"; echo is_array(\$s) && (\$s[\"DB\"][\"Connections\"][\"Default\"][\"dbname\"] ?? \"\") !== \"\" ? \"yes\" : \"no\";'"); + if ($filled !== 'yes') { + throw new \RuntimeException(parse("$secrets has no database connection yet: fill it in, then deploy again. Nothing went live.")); + } +}); + desc('Link the production fileadmin into the release'); task('typo3:fileadmin', function () { run('test -d {{fileadmin_path}}'); @@ -127,9 +148,11 @@ task('deploy', [ 'deploy:lock', 'deploy:release', 'rsync', + 'typo3:secrets:init', 'deploy:shared', 'typo3:fileadmin', 'deploy:writable', + 'typo3:secrets:check', // The schema has to exist before the new code starts serving traffic (adds and changes only). 'typo3:extension:setup', // deploy:publish == deploy:symlink, deploy:unlock, deploy:cleanup, deploy:success