Seravo / wordpress

The WordPress project layout used by many of Seravo's customers, suitable also for local development with Vagrant and git deployment
https://seravo.com
GNU General Public License v3.0
104 stars 53 forks source link

Run Gulp SASS compilation automatically on git post-receive hook #145

Closed ottok closed 3 years ago

ottok commented 4 years ago

Currently a git push production does not trigger a gulp run. We can't just bluntly start doing so, since we don't know if a project uses SASS nor if the gulpfile.js has been configured correctly.

If those are set up correctly, this addition would run Gulp:

--- a/scripts/git-hooks/post-receive
+++ b/scripts/git-hooks/post-receive
@@ -35,11 +35,15 @@ done
 # Check files which have triggers
 COMPOSER_CHANGED=false
 NGINX_CHANGED=false
+SCSS_CHANGED=false
 while read -r line; do
     if [ "$line" = "composer.json" ] || [ "$line" = "composer.lock" ]; then
       COMPOSER_CHANGED=true
     elif [ "$line" = "nginx/*.conf" ]; then
       NGINX_CHANGED=true
+    elif [[ "$line" =~ \.scss ]]; then
+      SCSS_CHANGED=true
     fi
 done <<< "$changed_files"

@@ -54,6 +58,10 @@ if $NGINX_CHANGED; then
   wp-restart-nginx
 fi

+if $SCSS_CHANGED; then
+  echo "Eeco: SASS files changed, running Gulp..."
+  gulp
+fi

If we some more smarts here, maybe we could test if gulpfile.json is configured (=modified from default, points to real directories) and run it. We could also consider shipping Gulp by default so the npm install step would be optional.

ottok commented 3 years ago

This was fixed in https://github.com/Seravo/seravocom/commit/c9d84670e3c730c0a0cc12bad1576c2834519247