Skip to content

Commit

Permalink
Stage aus Host-Alias ermitteln, Badge optimiert
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Oct 16, 2023
1 parent 1055c33 commit 2bf8905
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 9 additions & 2 deletions deployer/tasks/deploy/dump_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@

desc('Dump info about current deployment');
task('deploy:dump_info', static function () {
$host = get('alias');
$stage = get('labels')['stage'] ?? null;

if (null === $stage && in_array($host, ['staging', 'test', 'testing', 'live', 'prod', 'production'], true)) {
$stage = $host;
}

$branch = getenv('CI_COMMIT_REF_NAME') ?: get('branch') ?? onHost(host('local'), static fn () => run('{{bin/git}} rev-parse --abbrev-ref HEAD'));
$commit = getenv('CI_COMMIT_SHA') ?: onHost(host('local'), static fn () => run("{{bin/git}} rev-list $branch -1"));

$infos = [
'host' => get('alias'),
'stage' => get('labels')['stage'] ?? null,
'host' => $host,
'stage' => $stage,
'timestamp' => time(),
'branch' => $branch,
'commit' => $commit,
Expand Down
8 changes: 5 additions & 3 deletions lib/handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ public static function addBadge(rex_extension_point $ep): ?string
$ydeploy = rex_ydeploy::factory();

if ($ydeploy->isDeployed()) {
$badge = $ydeploy->getHost();
$host = $ydeploy->getHost();
$stage = $ydeploy->getStage();

if ($ydeploy->getStage()) {
$badge .= '' . ucfirst($ydeploy->getStage());
$badge = ucfirst($stage);
if ($host !== $stage) {
$badge = $host . '' . $badge;
}
} else {
$badge = 'Development';
Expand Down

0 comments on commit 2bf8905

Please sign in to comment.