0

I have a linux server as my a production environment, and my node repo is on github . When I push my code, if I want to deploy it , I need to .

>local
git push
ssh user@host

>remote
cd repo
git pull

I am using node forever to auto update my code , but it is still a very troublesome .

Is there any solution , like travis-ci or heroku , can Automatically deploy my code on github ?

elrrrrrrr
  • 894
  • 8
  • 15

1 Answers1

1

Travis-ci is for continuous integration (as its name) While Heroku is just a cloud platform. They are not for deployment.

My solution is to set up a git hook on your server, push to it to trigger the hook, and do whatever you want in that script.

for example, you can:

  1. cd ~/repo && mkdir myproj && cd myproj
  2. git init --bare
  3. edit ~/repo/myproj/hooks/post-update

    #!/bin/sh
    unset GIT_DIR;
    cd <your project-root>
    export NODE_ENV="product"
    git pull
    npm install
    pm2 restart <your app name>
    
  4. chmod +x ~/repo/myproj/hooks/post-update

now you can add your repo on server as one of your remotes

There's some services available to monitor your deployment, such as http://dploy.io/ and https://www.codeship.io/

Feel free to use them when your business grows up.

spud hsu
  • 26
  • 1
  • 1
  • I use the [dploy](http://dploy.io) to achieve automated deployment, although the server root permissions pay out feeling somewhat insecure . – elrrrrrrr Aug 20 '14 at 08:03