Created
February 19, 2012 01:53
-
-
Save jswartwood/1861587 to your computer and use it in GitHub Desktop.
Automatic Git deploys on Dreamhost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Replace this line with your real domain name | |
DOMAIN=mydomain.com | |
echo | |
echo "-= Transferring changes to $DOMAIN =-" | |
echo | |
# Clearing git env | |
unset GIT_DIR | |
unset GIT_WORK_TREE | |
cd ~/$DOMAIN | |
git pull | |
echo | |
echo "-= Done =-" | |
echo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace any brackets with real values | |
# Try to ssh in to DREAMHOST (ensure it no longer asks for a PW); you may want to restart Terminal | |
ssh [user]@[host] | |
cd ~ | |
mkdir [mydomain_com].git | |
cd [mydomain_com].git | |
git init --bare | |
vi hooks/post-receive | |
# Enter the code from the "post-receive" file (in this gist); save + quit | |
cd .. | |
git clone [mydomain_com].git [mydomain.com] | |
exit | |
# Add remote to git's list of remote repos | |
cd [some local git folder] | |
git remote add live ssh://[user]@[host]/~/[mydomain_com].git | |
# Push to production :) | |
git push live master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace any brackets with real values | |
# Before you start this, ensure that you have added shell (ssh) access for your hosted account (not just sftp/ftp). | |
# You may need to generate a new ssh key; if so, follow instructions to generate ssh key | |
ssh-keygen -t rsa | |
# Add to authorized keys on DREAMHOST | |
# For OSX: | |
cat ~/.ssh/id_rsa.pub | ssh [user]@[host] "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys" | |
# Else: | |
ssh-copy-id [user]@[host] |
Thanks!! Any idea why it doesn't work with method of setting the work tree of the bare repo?
Not sure if this is still working, I have setup the identical configuration with my sites domain and I get the following error:
remote:
remote: -= Transferring changes to mydomain.com =-
remote:
remote: fatal: Not a git repository (or any parent up to mount point /home)
remote: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
remote:
remote: -= Done =-
remote:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THANK YOU! This is brilliant - I needed to chmod 755 post-receive to get it to work.