olipo186 / Git-Auto-Deploy

Deploy your GitHub, GitLab or Bitbucket projects automatically on Git push events or webhooks using this small HTTP server written in Python. Continuous deployment in it's most simple form.
http://olipo186.github.io/Git-Auto-Deploy/
Other
1.39k stars 215 forks source link

How to display deploy script output inside main output window #135

Open yashilanka opened 8 years ago

yashilanka commented 8 years ago

Hi i create a Post-Deploy Script and it contain node js commands like npm install and so on. i want to display that nodejs command output to main script output area. i want to know is it possible to do, if yes can you guide me how to do it correctly this is my bash file.

i'm new to shell, know some stuff, but not a super user 👍

Conf File

please check my deploy value, this is i thought but it didn't work :(

{
//  "pidfilepath": "/var/run/git-auto-deploy/git-auto-deploy.pid",
  "logfilepath": "/var/log/git-auto-deploy.log",
  "host": "0.0.0.0",
  "port": 8080,
  "repositories": [
    {
      "url": "git@gitlab.com:****/***.git",
      "branch": "master",
      "remote": "origin",
      "path": "~/repositories/***",
      "deploy": "chmod u+x post-install.sh && bash -x post-install.sh < /dev/tty",
      "secret-token" : "************"
    }
  ]
}

Post-Deploy bash script

#!/bin/bash -x
cwd=$(pwd);
sudo apt-get install build-essential g++ -y

if [ ! -d "$cwd/node_modules" ]; then
  echo "Node packages not found, installation started !!!"
  sudo npm install -g node-gyp  && sudo npm install --unsafe-perm node-sass -g;
  npm install bower -g  && npm install gulp -g && npm install marked -g && npm install mimer -g && npm install ttf2woff2 -g && npm install varstream -g && npm install svgicons2svgfont -g;
  npm install;
fi

if [ ! -d "$cwd/bower_components" ]; then
  echo "Bower packages not found, installation started !!!"
  bower install --allow-root;
fi

while inotifywait -q -e modify "$cwd/bower.json"; do
    echo "New Package Detected on bower.json and bower is now installing";
    rm -rf cwd/bower_components;
    npm install bower -g;
    bower cache clean;
    bower install --allow-root;
done

while inotifywait -q -e modify "$cwd/package.json"; do
    echo "New Package Detected on package.json and node is now installing";
    rm -rf cwd/node_modules;
    npm cache clean;
    npm install;
done

if [ -d "$cwd/build" ]; then
  echo "Re-run Build Process"
  rm -rf cwd/build;
  npm run build-cli;
  exit;
else
  npm run build-cli;
  exit;
fi
realsby commented 8 years ago

I am very noob and bad in english.. Sorry for that.. Watching log file doesnt enough? tail -f /var/log/git-auto-deploy.log or why you dont just write your output to a file like "deploy": "/myrepo/deploy.sh > /deployscript.log"