Skip to content

Instantly share code, notes, and snippets.

@NoelDavies
Last active August 29, 2015 14:21
Show Gist options
  • Save NoelDavies/69517c27c5f6cefb9205 to your computer and use it in GitHub Desktop.
Save NoelDavies/69517c27c5f6cefb9205 to your computer and use it in GitHub Desktop.
Releases Script
#!/bin/sh
RELEASES_DIR=~/www/releases
SYMLINK_TO=~/www/current
CURRENT=`date +%Y%m%d%H%M%S`
RELEASE_DIR=$RELEASES_DIR/$CURRENT
## Initiate the new release
mkdir $RELEASE_DIR
cd $RELEASE_DIR
hg clone YOUR_REPO_URL .
## Custom Post-Clone stuff here
# You could have things like
# composer install
# php artisan cache:routes
# etc.
## End Custom Post-Clone stuff
## Update the current symlink to the current dir
ln -nfs $RELEASE_DIR $SYMLINK_TO
# Delete oldest dirs, leave latest 5
cd $RELEASES_DIR
cd ..
rm `ls -t | tail -n +6` -rf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment