-
Notifications
You must be signed in to change notification settings - Fork 1
Setup Push to Deploy
Since version 2.4, git has supported push to deploy. Push to deploy requires some configuration on server side git repository. Steps to take (in Ubuntu) are listed below:
-
Install the newest
git.sudo add-apt-repository ppa:git-core/ppa sudo apt-get update sudo apt-get install git
-
Install
Node.js+npm.curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs -
Install
pm2globally. PM2 is a production process manager for Node.js applications with a built-in load balancer.npm install -g pm2
-
Clone git repo to your home directory.
-
Add a hook named
post-updateinWeStudy/.git/hooks, and make it executable.#!/bin/sh git read-tree -u -m HEAD npm install --production pm2 restart ~/WeStudy/bin/www
-
Overwrite
WeStudy/.git/configwith the following:[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [receive] denyCurrentBranch = updateInstead -
Install dependencies
npm install
-
Start a node instance in
~/WeStudy/.pm2 start ./bin/www ## or to start on port 443 sudo apt-get install authbind sudo touch /etc/authbind/byport/443 sudo chown %user% /etc/authbind/byport/443 sudo chmod 755 /etc/authbind/byport/443 PORT=443 authbind --deep pm2 start ./bin/www -n live
Optional: Add this alias pm2='authbind --deep pm2' to bash_profile.
-
Go to your development environment, and switch to a branch you want to push.
git push -f <remote name> <branch name>:master
-
Set up ssh control master. Add the following to
~/.ssh/config.Host * ControlMaster auto ControlPath ~/.ssh/controlmasters/%r@%h:%pCreate the contolmaster folder
mkdir ~/.ssh/controlmasters