From c13114b0ccd80ecc9c9c59cc0324b0388d61fcfa Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 2 Nov 2021 21:16:46 -0700 Subject: [PATCH] Fix old version cleanup to sort by modified date I was sorting by version name, which _was_ reliable until I changed my version name format, and then a deploy cleaned up the version it had just deployed because it no longer sorted to the end! Rather than be dependent on a stable version name format, and set myself up for more surprises, I'm going to instead use the folder's modified time. While there could be surprising ways for folder timestamps to be updated, I expect it to be _more_ reliable overall. --- deploy/playbooks/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/playbooks/deploy.yml b/deploy/playbooks/deploy.yml index ecdcdf3..6c5b057 100644 --- a/deploy/playbooks/deploy.yml +++ b/deploy/playbooks/deploy.yml @@ -57,10 +57,10 @@ cmd: yarn install - name: Find older versions to clean up - # Print out all but the last 5 versions + # Print out all but the 5 last-recently-updated versions command: chdir: /srv/impress-2020/versions - cmd: bash -c 'ls | head -n -5' + cmd: bash -c 'ls -t | tail -n +6' register: versions_to_clean_up - name: Clean up older versions