Skip to content

Instantly share code, notes, and snippets.

@J3RN
Created October 20, 2015 02:31
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 J3RN/39fba3d597ea33a31dd4 to your computer and use it in GitHub Desktop.
Save J3RN/39fba3d597ea33a31dd4 to your computer and use it in GitHub Desktop.
A post-update Git hook that I use to deploy my portfolio site
#!/bin/sh
GIT_REPO=$HOME/portfolio.git
TMP_GIT_CLONE=$HOME/tmp_portfolio
PUBLIC_WWW=$HOME/www
touch $HOME/deploy
git clone $GIT_REPO $TMP_GIT_CLONE
cp -rv $TMP_GIT_CLONE/* $PUBLIC_WWW
rm -rf $TMP_GIT_CLONE
exit
@benlk
Copy link

benlk commented Oct 20, 2015

So if the current repo is A, it clones A into ~/tmp_portfolio, then copies ~/tmp_portfolio/* into ~/www?

Why not just cp -rv ../../* $PUBLIC_WWW ? ../.. in the context of post-update should be the repo, and that way you wouldn't need to keep a copy of portfolio.git in your $HOME.

Or am I missing something strange about the hosting provider?

@J3RN
Copy link
Author

J3RN commented Oct 20, 2015

Well, ../../ is just the git remote structure, and does not have the code. The code is probably accessible without cloning, but I believe it's just easier to clone it.

Explanatory image:
screen shot 2015-10-20 at 12 01 11

@benlk
Copy link

benlk commented Oct 20, 2015

Oh, projectname.git is a directory name and not a .git file. Okay, this makes a little more sense.

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