Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/free-disk-space.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Free disk space on EC2

on:
pull_request:
workflow_dispatch:

jobs:
free-disk:
runs-on: ubuntu-latest
steps:
- name: SSH in and report disk usage
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_URL }}
username: 'ubuntu'
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "=== Disk usage (df -h) ==="
df -h
echo ""
echo "=== Largest dirs in /home/ubuntu ==="
du -sh /home/ubuntu/* 2>/dev/null | sort -hr | head -20
echo ""
echo "=== Backend repo size breakdown ==="
du -sh /home/ubuntu/DishZero/backend/* 2>/dev/null | sort -hr
echo ""
echo "=== /tmp size ==="
du -sh /tmp 2>/dev/null || true
echo ""
echo "=== npm cache size ==="
du -sh ~/.npm 2>/dev/null || true
echo ""
echo "=== yarn cache size ==="
du -sh ~/.yarn 2>/dev/null || true

echo ""
echo "=== Cleanup: free space first (no extra writes), then clear caches ==="
cd /home/ubuntu/DishZero/backend
rm -rf node_modules
git gc --aggressive --prune=now
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
npm cache clean --force
echo ""
echo "=== Disk usage after cleanup ==="
df -h