Last active
November 18, 2025 12:03
-
-
Save jlabs/6989c9b0de088cea5e3e4380ab3d4cb2 to your computer and use it in GitHub Desktop.
Git hook for DDEV + Craft CMS changes on git pull
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Get changed files in the last merge | |
| changed_files=$(git diff-tree -r --name-only ORIG_HEAD HEAD) | |
| # If package.json or package-lock.json changed, run npm install | |
| if echo "$changed_files" | grep -q 'package.json'; then | |
| npm i | |
| fi | |
| # If composer.json changed, run composer install | |
| if echo "$changed_files" | grep -q 'composer.json'; then | |
| composer install | |
| fi | |
| # Always run these commands | |
| php craft up | |
| npm run build | |
| php craft clear-caches/all |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy to
.git/hooks/aspost-mergefile. It then runs whenever commits are pulled and checks for changes