Skip to content

Instantly share code, notes, and snippets.

@LosAlamosAl
Last active October 17, 2023 07:20
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save LosAlamosAl/0d2c5a4bbec37f0f4ea1d9926e32e4e1 to your computer and use it in GitHub Desktop.
Save LosAlamosAl/0d2c5a4bbec37f0f4ea1d9926e32e4e1 to your computer and use it in GitHub Desktop.
Deploy a GitHub-based static site to Dreamhost

Before begining, make sure your SSH keys are set so you can ssh to your Dreamhost account.

$ ssh-copy-id -i ~/.ssh/id_rsa.pub xxxxxx@cloverdale.dreamhost.com
(you'll need xxxxxx's password here)
$ ssh xxxxxx@cloverdale.dreamhost.com

On the Dreamhost server you should have a directory for your site (e.g. adubdub.com or ispeed.honeyimlost.com (if not, you'll need to make one). You now need to make a git repository for that site (at the same level in the tree) and initialize a bare repo:

$ mkdir ispeed.honeyimlost.com     # if necessary
$ mkdir ispeed.honeyimlost.com.git
$ cd !$
$ git init --bare

Now you need to create a hook that will, upon a push, copy the contents of the updated repository to the website directory:

$ vi hooks/post-receive (then add the following line)
git --work-tree=/home/xxxxxx/ispeed.honeyimlost.com --git-dir=/home/xxxxxx/ispeed.honeyimlost.com.git checkout -f
ZZ
$ chmod +x !$
$ exit

Now, back on your development machine, in the original git repo, add Dreamhost as a remote that will ALSO get pushed to when you push your updates:

$ git remote set-url --add --push origin ssh://xxxxxx@cloverdale.dreamhost.com/home/xxxxxx/ispeed.honeyimlost.com.git
$ git remote set-url --add --push origin git@losalamosal.github.com:losalamosal/jstest.git
$ git push origin +master:refs/heads/master   # only need to do once: force push

From now on, push as usual:

$ git push origin master
$ git push origin branchname

This is the reference post

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