Created
January 31, 2019 10:44
-
-
Save olivertappin/8a0e6abc79c6ac1e88a348d555756dee to your computer and use it in GitHub Desktop.
Atomic symlinked deployments
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
BASE="/var/www/project" | |
RELEASES="$BASE/releases" | |
RELEASE="$RELEASES/`date +%s`" | |
SHARED="$BASE/shared" | |
CACHE="$BASE/deploy-cache" | |
cp -a $CACHE $RELEASE | |
cd $RELEASE | |
####### [Pre-launch commands] ####### | |
composer install -va | |
####### [/Pre-launch commands] ####### | |
if [ $? -ne 0 ]; then echo "Pre-launch commands failed."; exit 1; fi | |
rm -f $RELEASES/current; ln -s $RELEASE $RELEASES/current; mv -f $RELEASES/current $BASE/ | |
cd $RELEASE | |
####### [Post-launch commands] ####### | |
####### [/Post-launch commands] ####### | |
if [ $? -ne 0 ]; then echo "Post-launch commands failed, but the current application symlink was updated."; exit 1; fi | |
echo "Cleaning up old releases" | |
\ls -1d $RELEASES/* | \sort -rg | \tail -n +11 | \xargs /bin/rm -rf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment