@@ -5,22 +5,21 @@ ENV EXTENSION_KEY "nr_textdb"
55ENV DDEV_SITENAME "nr-textdb"
66ENV GITHUB_URL "https://github.com/netresearch/t3x-nr-textdb"
77
8- # Get git info from build context (captured on host before build)
9- ARG GIT_BRANCH="unknown"
10- ARG GIT_COMMIT="unknown"
11- ARG GIT_PR="unknown"
12-
13- # Create PHP-based landing page with dynamic git info from build args
14- RUN cat > /var/www/html/index.php << PHPEOF
8+ # Remove default Apache index.html and create PHP-based landing page
9+ RUN rm -f /var/www/html/index.html
10+ RUN cat > /var/www/html/index.php << 'PHPEOF'
1511<?php
16- // Get git info from Docker build args
17- \$ gitBranch = '${GIT_BRANCH}' ;
18- \$ gitCommit = '${GIT_COMMIT}' ;
19- \$ prNumber = '${GIT_PR}' !== 'unknown' ? '${GIT_PR}' : null;
12+ // Get git info from runtime file (updated on each ddev start)
13+ $gitInfoFile = '/var/www/html/.git-info.json' ;
14+ $gitInfo = file_exists($gitInfoFile) ? json_decode(file_get_contents($gitInfoFile), true) : [];
15+
16+ $gitBranch = $gitInfo['branch' ] ?? 'unknown' ;
17+ $gitCommit = $gitInfo['commit' ] ?? 'unknown' ;
18+ $prNumber = isset($gitInfo['pr' ]) && $gitInfo['pr' ] !== 'unknown' ? $gitInfo['pr' ] : null;
2019
21- \ $ githubUrl = 'https://github.com/netresearch/t3x-nr-textdb' ;
22- \ $ branchUrl = \ $ githubUrl && \ $ gitBranch !== 'unknown' ? \ $ githubUrl . '/tree/' . urlencode(\ $ gitBranch) : null;
23- \ $ prUrl = \ $ githubUrl && \ $ prNumber ? \ $ githubUrl . '/pull/' . \ $ prNumber : null;
20+ $githubUrl = 'https://github.com/netresearch/t3x-nr-textdb' ;
21+ $branchUrl = $githubUrl && $gitBranch !== 'unknown' ? $githubUrl . '/tree/' . urlencode($gitBranch) : null;
22+ $prUrl = $githubUrl && $prNumber ? $githubUrl . '/pull/' . $prNumber : null;
2423?>
2524<!DOCTYPE html>
2625<html lang="en" >
@@ -55,19 +54,19 @@ RUN cat > /var/www/html/index.php << PHPEOF
5554<body>
5655 <div class="container" >
5756 <h1>🚀 EXT:nr_textdb Development Environment</h1>
58- <?php if (\ $ gitBranch !== 'unknown' || \ $ prNumber): ?>
57+ <?php if ($gitBranch !== 'unknown' || $prNumber): ?>
5958 <div class="git-info" >
60- <?php if (\ $ branchUrl): ?>
61- <a href="<?= htmlspecialchars(\ $ branchUrl) ?>" target="_blank" title="View branch on GitHub" >
62- 🌿 <?= htmlspecialchars(\ $ gitBranch) ?><?php if (\ $ gitCommit !== 'unknown' ): ?> @ <?= htmlspecialchars(\ $ gitCommit) ?><?php endif; ?>
59+ <?php if ($branchUrl): ?>
60+ <a href="<?= htmlspecialchars($branchUrl) ?>" target="_blank" title="View branch on GitHub" >
61+ 🌿 <?= htmlspecialchars($gitBranch) ?><?php if ($gitCommit !== 'unknown' ): ?> @ <?= htmlspecialchars($gitCommit) ?><?php endif; ?>
6362 </a>
64- <?php elseif (\ $ gitBranch !== 'unknown' ): ?>
65- 🌿 <?= htmlspecialchars(\ $ gitBranch) ?><?php if (\ $ gitCommit !== 'unknown' ): ?> @ <?= htmlspecialchars(\ $ gitCommit) ?><?php endif; ?>
63+ <?php elseif ($gitBranch !== 'unknown' ): ?>
64+ 🌿 <?= htmlspecialchars($gitBranch) ?><?php if ($gitCommit !== 'unknown' ): ?> @ <?= htmlspecialchars($gitCommit) ?><?php endif; ?>
6665 <?php endif; ?>
67- <?php if (\ $ prUrl): ?>
66+ <?php if ($prUrl): ?>
6867 <span class="separator" >|</span>
69- <a href="<?= htmlspecialchars(\ $ prUrl) ?>" target="_blank" title="View pull request" >
70- 🔀 PR #<?= htmlspecialchars(\ $ prNumber) ?>
68+ <a href="<?= htmlspecialchars($prUrl) ?>" target="_blank" title="View pull request" >
69+ 🔀 PR #<?= htmlspecialchars($prNumber) ?>
7170 </a>
7271 <?php endif; ?>
7372 </div>
0 commit comments