Created
December 10, 2010 21:30
-
-
Save jmccartie/736859 to your computer and use it in GitHub Desktop.
Clone repo, prompt for hash, checkout hash, symlink production folder
This file contains 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 -e | |
# Set the variables below to match what your setup should be | |
# | |
# Your repo URL | |
# Example: [email protected]:jmccartie/php-url-shortener.git | |
clone_url= | |
# | |
# Builds dir | |
# | |
# The place to hold your builds. Your production folder will symlink to one of these | |
# Example: builds_dir=/var/www/builds/myawesomesite | |
builds_dir= | |
# | |
# Live dir | |
# | |
# The folder your webserver is actually looking at. This will be a symlink to the current live build in yours builds_dir | |
# Example: builds_dir=/var/www/myawesomesite | |
live_dir= | |
# | |
# | |
# | |
# | |
# Begin the business. | |
# | |
# | |
# | |
# | |
# | |
# Clone repo | |
git clone $clone_url $builds_dir/temp | |
# Output git log | |
cd $builds_dir/temp | |
git log -5 | cat | |
echo Choose a version to deploy... | |
read ANSWER | |
if [[ "$ANSWER" == "" ]]; then | |
echo You did not provide a version. | |
rm -rf $builds_dir/temp | |
exit 0 | |
else | |
exporthash=`echo $ANSWER | cut -c -10` | |
fi | |
target_dir="$builds_dir/$exporthash" | |
# Check to make sure dir does not already exist | |
if [ -d $target_dir ]; then | |
echo -n This directory already exists | |
exit 0 | |
fi | |
echo -n Will attempt to deploy version "$ANSWER" to "$target_dir" | |
# move | |
mv $builds_dir/temp $target_dir | |
cd $target_dir | |
# create symlink | |
ln -nfs $target_dir $live_dir | |
# Restarts | |
# | |
# example: service nginx restart | |
# example: service php_cgi restart | |
echo -n Done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment