mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 17:22:41 +01:00
36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
namespace Deployer;
|
|
|
|
use Deployer\Exception\Exception;
|
|
use function Deployer\Support\str_contains;
|
|
|
|
desc('Preparing host for deploy');
|
|
task('deploy:setup', function () {
|
|
// Check if shell is POSIX-compliant
|
|
$result = run('echo $0');
|
|
|
|
if (!str_contains($result, 'bash') && !str_contains($result, 'sh')) {
|
|
throw new \RuntimeException(
|
|
'Shell on your server is not POSIX-compliant. Please change to sh, bash or similar.'
|
|
);
|
|
}
|
|
|
|
run('if [ ! -d {{deploy_path}} ]; then mkdir -p {{deploy_path}}; fi');
|
|
cd('{{deploy_path}}');
|
|
|
|
// Check for existing /current directory (not symlink)
|
|
$result = test('[ ! -L {{current_path}} ] && [ -d {{current_path}} ]');
|
|
if ($result) {
|
|
throw new Exception('There already is a directory (not symlink) in ' . get('current_path') . '. Remove this directory so it can be replaced with a symlink for atomic deployments.');
|
|
}
|
|
|
|
// Create metadata .dep dir.
|
|
run("if [ ! -d .dep ]; then mkdir .dep; fi");
|
|
|
|
// Create releases dir.
|
|
run("if [ ! -d releases ]; then mkdir releases; fi");
|
|
|
|
// Create shared dir.
|
|
run("if [ ! -d shared ]; then mkdir shared; fi");
|
|
});
|