Skip to content

Instantly share code, notes, and snippets.

@samholmes
Created March 2, 2018 21:43
Show Gist options
  • Save samholmes/a54d4a2392153e6ab1ae10b825381881 to your computer and use it in GitHub Desktop.
Save samholmes/a54d4a2392153e6ab1ae10b825381881 to your computer and use it in GitHub Desktop.
Shell script to make git deployable production environments
#!/bin/sh
NAME=$1
DIR=$PWD
if [ ! -d "$DIR/$NAME" ]; then
mkdir "$NAME"
fi
if [ ! -d "$DIR/repos" ]; then
mkdir repos
fi
if [ ! -d "$DIR/repos/$NAME" ]; then
mkdir "$DIR/repos/$NAME"
fi
cd "$DIR/repos/$NAME"
git init --bare
echo "#!/bin/sh
export GIT_WORK_TREE=$DIR/$NAME
git checkout -f master
cd $DIR/$NAME
npm run prod-update" > hooks/post-update
chmod 755 hooks/post-update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment