Skip to content

Instantly share code, notes, and snippets.

@toledox82
Forked from LosAlamosAl/dreamhost-deploy.md
Last active December 9, 2020 00:49
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 toledox82/1429cd5abbfdcd130819aa88e0e88f4a to your computer and use it in GitHub Desktop.
Save toledox82/1429cd5abbfdcd130819aa88e0e88f4a 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.

Mac

$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@domain.com
$ ssh username@domain.com

Windows

$ scp ~/.ssh/id_rsa.pub [user]@[hostname]:~/.ssh/authorized_keys
$ ssh username@domain.com

You now need to make a git repository for that site (at the same level in the tree) and initialize a bare repo:

$ mkdir domain.com     # if necessary
$ mkdir domain.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/username/domain.com --git-dir=/home/username/domain.com.git checkout -f

$ chmod +x hooks/post-receive
$ 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 add prod ssh://username@domain.com/home/username/domain.com.git
$ git push prod +master:refs/heads/master   # only need to do once: force push

From now on, push as usual:

$ git push prod master

This is the reference post

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