mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 00:32:25 +01:00
Add status command
This commit is contained in:
parent
c88ebe275f
commit
84c9f6bb58
@ -11,6 +11,7 @@ require __DIR__ . '/deploy/release.php';
|
||||
require __DIR__ . '/deploy/rollback.php';
|
||||
require __DIR__ . '/deploy/setup.php';
|
||||
require __DIR__ . '/deploy/shared.php';
|
||||
require __DIR__ . '/deploy/status.php';
|
||||
require __DIR__ . '/deploy/symlink.php';
|
||||
require __DIR__ . '/deploy/update_code.php';
|
||||
require __DIR__ . '/deploy/vendors.php';
|
||||
|
@ -1,6 +1,25 @@
|
||||
<?php
|
||||
namespace Deployer;
|
||||
|
||||
// Holds name of deployed branch, tag or revision.
|
||||
set('git_target', function () {
|
||||
$t = '';
|
||||
$branch = get('branch');
|
||||
if (!empty($branch)) {
|
||||
$t = $branch;
|
||||
}
|
||||
if (input()->hasOption('tag') && !empty(input()->getOption('tag'))) {
|
||||
$t = input()->getOption('tag');
|
||||
}
|
||||
if (input()->hasOption('revision') && !empty(input()->getOption('revision'))) {
|
||||
$t = input()->getOption('revision');
|
||||
}
|
||||
if (empty($t)) {
|
||||
$t = "HEAD";
|
||||
}
|
||||
return $t;
|
||||
});
|
||||
|
||||
task('deploy:info', function () {
|
||||
$what = '';
|
||||
$branch = get('branch');
|
||||
|
@ -123,7 +123,7 @@ task('deploy:release', function () {
|
||||
$date = run('date +"%Y%m%d%H%M%S"');
|
||||
|
||||
// Save metainfo about release
|
||||
run("echo '$date,{{release_name}}' >> .dep/releases");
|
||||
run("echo '$date,{{release_name}},{{user}},{{git_target}}' >> .dep/releases");
|
||||
|
||||
// Make new release
|
||||
run("mkdir -p $releasePath");
|
||||
|
29
recipe/deploy/status.php
Normal file
29
recipe/deploy/status.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Deployer;
|
||||
|
||||
use Deployer\Support\Csv;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
|
||||
task('status', function () {
|
||||
$metainfo = Csv::parse(run('cat {{deploy_path}}/.dep/releases'));
|
||||
$releasesList = get('releases_list');
|
||||
$currentRelease = run('basename `realpath {{current_path}}`');
|
||||
|
||||
$metainfo = array_filter($metainfo, function ($r) use ($releasesList) {
|
||||
return in_array($r[1], $releasesList, true);
|
||||
});
|
||||
foreach ($metainfo as &$r) {
|
||||
$r[0] = \DateTime::createFromFormat("YmdHis", $r[0])->format("Y-m-d H:i:s");
|
||||
if ($r[1] === $currentRelease) {
|
||||
$r[1] = "<info>$r[1]</info>";
|
||||
}
|
||||
}
|
||||
|
||||
$table = new Table(output());
|
||||
$table
|
||||
->setHeaderTitle(currentHost()->getAlias())
|
||||
->setHeaders(['Date', 'Release', 'Author', 'Target'])
|
||||
->setRows($metainfo);
|
||||
$table->render();
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user