Skip to content

Instantly share code, notes, and snippets.

@michaeldyrynda
Created November 20, 2015 22:28
Show Gist options
  • Save michaeldyrynda/31e98d51180c99e44091 to your computer and use it in GitHub Desktop.
Save michaeldyrynda/31e98d51180c99e44091 to your computer and use it in GitHub Desktop.
Clean old releases in Envoy
@task('clean_old_releases')
# This lists our releases by modification time and delete all but the 3 most recent.
purging=$(ls -dt {{ $release_dir }}/* | tail -n +3);
if [ "$purging" != "" ]; then
echo Purging old releases: $purging;
rm -rf $purging;
else
echo "No releases found for purging at this time";
fi
@endtask
@wyred
Copy link

wyred commented Jun 11, 2020

To anyone else using this piece of code, ensure that your $release_dir is properly set or you'll end up wiping out everything on your server like I did : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment