Skip to content

Commit 511d913

Browse files
committed
feat: Add automatic git info updates on ddev start/restart
- Post-start hook captures branch, commit, and PR info - Writes JSON file to /var/www/html/.git-info.json - No manual commands required - fully automatic - Updates on every ddev start/restart
1 parent c7578b1 commit 511d913

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.ddev/config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,17 @@ additional_hostnames:
1313
- v13.nr-textdb
1414
additional_fqdns: []
1515
use_dns_when_possible: true
16+
webimage_extra_dockerfiles:
17+
- web-build
18+
hooks:
19+
post-start:
20+
- exec-host: |
21+
# Capture git info and write to container on every ddev start
22+
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
23+
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
24+
PR=$(gh pr view --json number -q .number 2>/dev/null || echo "unknown")
25+
26+
# Write git info as JSON to web container
27+
ddev exec "printf '{\"branch\":\"%s\",\"commit\":\"%s\",\"pr\":\"%s\"}' '$BRANCH' '$COMMIT' '$PR' > /var/www/html/.git-info.json"
28+
29+
echo "📋 Git info updated: Branch=$BRANCH, Commit=$COMMIT, PR=$PR"

0 commit comments

Comments
 (0)