Skip to content

Instantly share code, notes, and snippets.

@oscar-g
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscar-g/d346eebaf51e4003f676 to your computer and use it in GitHub Desktop.
Save oscar-g/d346eebaf51e4003f676 to your computer and use it in GitHub Desktop.
deploy a webfaction.com Node application using Git
# we'll ignore webfaction's node and npm
# but we'll keep bin/start and bin/stop
node_modules/
lib/npm/
bin/node
bin/npm
#ignore the process number file too
run/
* All of this is basically as described [Quick and Dirty Git Deployment](http://someguyjeremy.com/blog/quick-and-dirty-git-deployment).
* Also see: [A Web Focused Git Workflow](http://joemaller.com/990/a-web-focused-git-workflow/).
*
## On the server
- Make bare repo in a private folder and move into it
- git config
- core.bare False
- core.worktree [app directory]
- receive.denycurrentbranch ignore
- Add gitignore to the worktree
- Add and commit files from worktree
- write post-receive hook in repo index
## On local machine
- git remote add source ssh://user@server.webfaction.com/~/repos/repo
- git pull source master
- make changes and commit
- git push source master
#!/bin/sh
#script modofied from: http://someguyjeremy.com/blog/quick-and-dirty-git-deployment
#also see: http://joemaller.com/990/a-web-focused-git-workflow/
read OLDREV NEWREV REFNAME
WORKTREE=`git config core.worktree`
GITDIR=`pwd`
NPM=$WORKTREE/bin/npm
# stop the node app
$WORKTREE/bin/stop
# checkout current commit
umask 002 && git reset --hard
# checkout submodules (you must be in the worktree to do this)
cd $WORKTREE
git --git-dir="$GITDIR" submodule update --init
git --git-dir="$GITDIR" submodule foreach git reset --hard
# install node modules
$NPM install
# start the app again
bin/start
# Not sure if this works on webfaction?
# fix permissions
#FILES=`git --git-dir=${GITDIR} diff ${OLDREV}..${NEWREV} --name-only --diff-filter=ACMRTUXB`
#for F in $FILES; do
# chown git:www-data "$F"
#done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment