2013年4月25日 星期四

[NodeJS] Auto deploy by github hook

Github hook service會在有新的commit的時候觸發hook API(bitbucket也有), 這可以用在

  • 遠端Server自動部署, 才不用每次都ssh到遠端Server去git pull然後deploy一遍
  • 自動發訊息到團隊的協作平台或是寄發Email
  • ...

Github本身支援很多好用的服務, 那我是用WebHook在我的主機上, 當有commit時會觸發Server上的hook, 然後執行一個Shell Script, 自動git pull然後重新啓動我的Web Service

$ cd /var/web/project
$ git pull
$ forever restart /var/web/project/app.js

Code
https://github.com/hankwang/node-github-hook-deploy


Related Posts Plugin for WordPress, Blogger...