Skip to content

Instantly share code, notes, and snippets.

@adriano-di-giovanni
Created May 23, 2014 17:12
Show Gist options
  • Save adriano-di-giovanni/11c648c82a29ab4f16e3 to your computer and use it in GitHub Desktop.
Save adriano-di-giovanni/11c648c82a29ab4f16e3 to your computer and use it in GitHub Desktop.
Automated Node.js application deployment using git and nvm
#!/usr/bin/env sh
set -e
read sha1_old sha1_new refname
WORK_TREE=/srv/admin/apps/si-mysql-maint
NVM="${HOME}/.nvm/nvm.sh"
mkdir -p ${WORK_TREE}
git --work-tree=${WORK_TREE} clean -fd
git --work-tree=${WORK_TREE} checkout ${sha1_new} --force
if [ -s ${NVM} ]; then
cd ${WORK_TREE}
NVM_DIR=`dirname ${NVM}`
export NVM_DIR
. ${NVM}
npm install
fi
@adriano-di-giovanni
Copy link
Author

Specifying ${sha1_new} to git checkout lets you checkout branches and tags.
Don't know why I couldn't find this solution reported. It works. Any downside?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment