2014-07-04 12:15:38 +04:00
|
|
|
#!/usr/bin/env php
|
2013-07-11 15:47:09 +04:00
|
|
|
<?php
|
2016-01-11 12:51:59 +07:00
|
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
2013-07-11 15:47:09 +04:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2016-04-04 16:22:00 +07:00
|
|
|
// Deployer constants
|
2020-04-25 23:00:08 +03:00
|
|
|
|
2016-03-11 14:59:34 +01:00
|
|
|
define('DEPLOYER', true);
|
2016-04-04 16:22:00 +07:00
|
|
|
define('DEPLOYER_BIN', __FILE__);
|
2021-10-12 21:20:05 +00:00
|
|
|
define('DEPLOYER_VERSION', '7.0.0-master');
|
2016-03-11 12:01:59 +01:00
|
|
|
|
2020-10-08 01:40:08 +02:00
|
|
|
// Check for min. php version requirement
|
|
|
|
if (PHP_VERSION_ID < 70300) {
|
2018-10-17 14:10:48 +09:00
|
|
|
fwrite(
|
|
|
|
STDERR,
|
2020-10-08 01:40:08 +02:00
|
|
|
'Upgrade to php 7.3' . PHP_EOL .
|
|
|
|
'Deployer supports only php 7.3 and above.' . PHP_EOL .
|
|
|
|
'If you want to use older php versions you should use older Deployer versions' . PHP_EOL
|
2017-05-16 17:26:00 +07:00
|
|
|
);
|
2018-10-17 14:10:48 +09:00
|
|
|
exit(1);
|
2017-05-16 17:26:00 +07:00
|
|
|
}
|
|
|
|
|
2020-04-25 23:00:08 +03:00
|
|
|
// Errors to exception
|
2014-07-07 17:44:06 +04:00
|
|
|
|
2020-04-25 23:00:08 +03:00
|
|
|
set_error_handler(function ($severity, $message, $filename, $lineno) {
|
|
|
|
if (error_reporting() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (error_reporting() & $severity) {
|
|
|
|
throw new ErrorException($message, 0, $severity, $filename, $lineno);
|
|
|
|
}
|
|
|
|
});
|
2014-11-29 22:11:11 +03:00
|
|
|
|
2020-04-25 23:00:08 +03:00
|
|
|
// Detect deploy.php script
|
|
|
|
$deployFile = null;
|
2020-10-15 22:12:17 +02:00
|
|
|
foreach ($argv as $i => $arg) {
|
|
|
|
if (preg_match('/^(-f|--file)$/', $arg, $match) && $i + 1 < count($argv)) {
|
|
|
|
$deployFile = $argv[$i + 1];
|
|
|
|
}
|
|
|
|
if (preg_match('/^(-f|--file)=(?<file>.+?)$/', $arg, $match)) {
|
|
|
|
$deployFile = $match['file'];
|
|
|
|
}
|
2020-04-25 23:00:08 +03:00
|
|
|
|
2020-10-15 22:12:17 +02:00
|
|
|
if (!empty($deployFile)) {
|
|
|
|
$deployFile = ($deployFile[0] === '/' ? '' : getcwd() . '/') . $deployFile;
|
|
|
|
}
|
2019-08-13 18:00:03 +02:00
|
|
|
}
|
2020-10-15 22:12:17 +02:00
|
|
|
$lookUp = function (string $name): ?string
|
|
|
|
{
|
|
|
|
$dir = getcwd();
|
|
|
|
for ($i = 0; $i < 10; $i++) {
|
|
|
|
$path = "$dir/$name";
|
|
|
|
if (is_readable($path)) {
|
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
$dir = dirname($dir);
|
2016-11-07 20:43:31 +07:00
|
|
|
}
|
2020-10-15 22:12:17 +02:00
|
|
|
return null;
|
|
|
|
};
|
|
|
|
if (empty($deployFile)) {
|
|
|
|
$deployFile = $lookUp('deploy.php');
|
|
|
|
}
|
|
|
|
if (empty($deployFile)) {
|
|
|
|
$deployFile = $lookUp('deploy.yaml');
|
2014-11-29 22:11:11 +03:00
|
|
|
}
|
2014-07-04 13:39:57 +04:00
|
|
|
|
2020-04-25 23:00:08 +03:00
|
|
|
// Detect autoload location
|
2016-11-12 17:02:13 +07:00
|
|
|
|
|
|
|
$autoload = [
|
2020-04-25 23:00:08 +03:00
|
|
|
dirname($deployFile) . '/vendor/autoload.php',
|
2016-11-12 17:02:13 +07:00
|
|
|
__DIR__ . '/../../../autoload.php',
|
|
|
|
__DIR__ . '/../vendor/autoload.php'
|
|
|
|
];
|
|
|
|
|
|
|
|
$includes = [
|
2020-04-25 23:00:08 +03:00
|
|
|
dirname($deployFile) . '/vendor/deployer/deployer',
|
2016-11-12 17:02:13 +07:00
|
|
|
__DIR__ . '/../../../deployer/deployer',
|
|
|
|
__DIR__ . '/../'
|
|
|
|
];
|
|
|
|
|
|
|
|
$includePath = false;
|
|
|
|
for ($i = 0; $i < count($autoload); $i++) {
|
2016-11-12 18:16:50 +07:00
|
|
|
if (file_exists($autoload[$i]) && file_exists($includes[$i])) {
|
2016-11-12 17:02:13 +07:00
|
|
|
require $autoload[$i];
|
|
|
|
$includePath = $includes[$i];
|
2020-04-25 23:00:08 +03:00
|
|
|
goto run;
|
2016-11-12 17:02:13 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-25 23:00:08 +03:00
|
|
|
fwrite(
|
|
|
|
STDERR,
|
|
|
|
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
|
|
|
|
'wget http://getcomposer.org/composer.phar' . PHP_EOL .
|
|
|
|
'php composer.phar install' . PHP_EOL
|
|
|
|
);
|
|
|
|
exit(1);
|
2016-11-12 17:02:13 +07:00
|
|
|
|
2020-04-25 23:00:08 +03:00
|
|
|
run:
|
2016-11-12 17:02:13 +07:00
|
|
|
set_include_path($includePath . PATH_SEPARATOR . get_include_path());
|
2020-11-04 19:20:23 +01:00
|
|
|
define('DEPLOYER_DEPLOY_FILE', $deployFile);
|
2021-09-07 10:03:01 +02:00
|
|
|
define('DEPLOYER_ROOT', getenv('DEPLOYER_ROOT') !== false ? getenv('DEPLOYER_ROOT') : dirname($deployFile));
|
2020-04-25 23:00:08 +03:00
|
|
|
\Deployer\Deployer::run(DEPLOYER_VERSION, $deployFile);
|