Last active
August 29, 2015 14:05
-
-
Save oscar-g/d346eebaf51e4003f676 to your computer and use it in GitHub Desktop.
deploy a webfaction.com Node application using Git
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
# 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/ |
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
* 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://[email protected]/~/repos/repo | |
- git pull source master | |
- make changes and commit | |
- git push source master |
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
#!/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