Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
Created January 5, 2015 02:36
Show Gist options
  • Select an option

  • Save jeremyfelt/3b119d90c343eaaa82aa to your computer and use it in GitHub Desktop.

Select an option

Save jeremyfelt/3b119d90c343eaaa82aa to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Post receive deploy script for news.wsu.edu
#
# The master branch of the news.wsu.edu repository should be cloned from the
# origin repository into the /var/repos/news.wsu.edu/ directory on the server.
#
# A bare git repository should be created in /var/repos/news.wsu.edu.git/ with
# `git init --bare`.
#
# This file should be moved to /var/repos/news.wsu.edu.git/hooks/post-receive
# and made executable by the owner. `chmod u+x post-receive`.
# Project name, to make other variables easier to set.
project=news.wsu.edu
# Source directory for the primary files.
source_dir=/var/repos/"$project"/
# Destination directory for production files.
destination_dir=/var/www/"$project"/
echo "Updating with latest changes from master..."
# Unset the current GIT_DIR to unconfuse git.
unset GIT_DIR
# Change into the actual directory and pull latest master changes.
cd "$source_dir" && git fetch --all && git pull origin master
# Sync the latest master with current production code.
rsync -rlgDh --delete --exclude-from '/var/repos/news.wsu.edu/.rsync-exclude' "$source_dir" "$destination_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment