Skip to content

Commit d66f032

Browse files
Clean old deployment directories (#1321)
Fix #1300 ```sh cd $(RELEASES_DIR) && \ ls -1dt */ | # list dirs by modification time grep -v "^current/?$$" | # skip the 'current' symlink grep -v "^$(TIMESTAMP)/$$" | # skip the one we just deployed tail -n +4 | # keep the latest 3 xargs -r echo rm -rf # delete the rest (dry-mode with echo) ``` with "echo" in the command it's dry-mode example output ![image](https://github.com/user-attachments/assets/934352c5-61f6-4c79-bb90-8a923feed622) --------- Co-authored-by: Mia Bajić <[email protected]>
1 parent 317f28b commit d66f032

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ preview:
5757
$(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
5858
@echo "\n\n**** Preview complete.\n\n"
5959
@echo "Open the preview site at: $(PREVIEW_SITE_URL)\n\n"
60+
@echo "\n**** Cleaning up old releases (keep latest 1, skip 'current')...\n"
61+
$(REMOTE_CMD) "bash -c '\
62+
cd $(RELEASES_DIR) && \
63+
echo \"[INFO] Cleaning:\" && \
64+
ls -1dt */ \
65+
| sed \"s:/*\\\$$::\" \
66+
| grep -v ^current\\\$$ \
67+
| grep -v ^$(TIMESTAMP)\\\$$ \
68+
| tail -n +2 \
69+
| xargs -r -I{} echo rm -rf \"{}\"'"
6070

6171

6272
ifeq ($(FORCE_DEPLOY), true)

0 commit comments

Comments
 (0)