Created
May 19, 2015 15:11
-
-
Save pcanterini/05668823f01d350d9c52 to your computer and use it in GitHub Desktop.
Ubuntu nodejs git hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ubuntu server setup | |
adduser deploy sudo | |
# on your machine | |
# ssh-copy-id deploy@IPADDRESS | |
# ssh deploy@IPADDRESS -i yoursakeyfile | |
# edit /etc/ssh/ssh_config set PasswordAuthentication to 'no' | |
# run service ssh restart to restart ssh | |
# back on the server | |
sudo apt-get update | |
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev | |
# install nodejs | |
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - | |
sudo apt-get install -y nodejs | |
# create git repo | |
mkdir project.git | |
cd project.git | |
git init --bare | |
# Create/edit post receive hook and don't forget to chmod +x post-receive | |
### start ### | |
#!/bin/bash | |
while read oldrev newrev ref | |
do | |
branch=`echo $ref | cut -d/ -f3` | |
GIT_WORK_TREE=/home/deploy/publishing-templates git checkout -f $branch | |
done | |
cd /home/deploy/publishing-templates/app | |
#git pull hub master | |
npm install | |
gulp all | |
### end ### | |
# dont forget to create deploy folder in same folder where .git bare repo is | |
# Install nginx | |
sudo apt-get install nginx | |
# Edit nginx config file | |
sudo vi /etc/nginx/sites-available/default | |
# Restart nginx | |
sudo service nginx restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment