diff --git a/git-post-receive b/git-post-receive new file mode 100644 index 0000000..f9aba5f --- /dev/null +++ b/git-post-receive @@ -0,0 +1,54 @@ +#!/bin/sh + +BUILD_ANGULAR_ARG=$1 +BUILD_ANGULAR=false +if [ "$BUILD_ANGULAR_ARG" = -ng ]; then + BUILD_ANGULAR=true +fi + +echo "Build Angular = $BUILD_ANGULAR" + +cd /home/ofbbutte/webapps/ofb_angular/ +echo "Node Version" +bin/node --version +echo "NPM Version" +bin/node bin/npm --version +echo "Angular CLI Version" +bin/node tempcheckout/Client/node_modules/@angular/cli/bin/ng --version + +if [ "$BUILD_ANGULAR" = true ]; then + cd tempcheckout/Client + echo "Pruning Client Node Modules" + ../../bin/node ../../bin/npm prune --silent + echo "Installing Client Node Modules" + ../../bin/node ../../bin/npm install --silent + echo "Building Angular Application" + ../../bin/node node_modules/@angular/cli/bin/ng build --prod + cd ../../ + rm -r -f www/ + mv tempcheckout/Server/www/ www/ +else + echo "Skipping Building Angular Application" +fi + +cd tempcheckout/Server/src +echo "Pruning Server Node Modules" +../../../bin/node ../../../bin/npm prune --silent +echo "Installing Server Node Modules" +../../../bin/node ../../../bin/npm install --silent +cd ../../../ +rm -r -f src/ +mv tempcheckout/Server/src/ src/ +echo "Remove start and stop script files" +rm -f bin/start +rm -f bin/stop +echo "Copying start and stop script files" +mv tempcheckout/Server/bin/start bin/start +mv tempcheckout/Server/bin/stop bin/stop +echo "Modifying permissions on start and stop script files to be executable" +chmod +x bin/start +chmod +x bin/stop +echo "Running stop script file" +bin/stop +echo "Running start script file" +bin/start