ci(staging): aggressive disk cleanup to prevent ENOSPC during npm ci
Some checks failed
Deploy Staging (terry-wallet-login) / deploy (push) Failing after 2s
Some checks failed
Deploy Staging (terry-wallet-login) / deploy (push) Failing after 2s
- wipe all stale act workspaces (keep only current run's dir) - clear ~/.npm/_cacache and setup-node cache fully - docker system prune -af --volumes - apt/yum cache clean, journald vacuum to 100M - /tmp older than 30min instead of 120min
This commit is contained in:
@@ -15,23 +15,53 @@ jobs:
|
||||
set +e
|
||||
echo "=== Disk before cleanup ==="
|
||||
df -h
|
||||
du -sh "$HOME/.cache/act" "$HOME/.npm" "$HOME/actions-runner/_work" 2>/dev/null
|
||||
|
||||
# Identify current act workspace (most recently modified dir) and keep it; wipe the rest.
|
||||
if [ -d "$HOME/.cache/act" ]; then
|
||||
du -sh "$HOME/.cache/act" 2>/dev/null
|
||||
find "$HOME/.cache/act" -mindepth 1 -maxdepth 1 -type d -mmin +60 -exec rm -rf {} + 2>/dev/null
|
||||
CURRENT_ACT=$(ls -1dt "$HOME/.cache/act"/*/ 2>/dev/null | head -1 || true)
|
||||
echo "Preserving current act dir: ${CURRENT_ACT:-<none>}"
|
||||
for d in "$HOME/.cache/act"/*/; do
|
||||
[ -d "$d" ] || continue
|
||||
if [ "$d" != "$CURRENT_ACT" ]; then
|
||||
echo "Removing stale act workspace: $d"
|
||||
rm -rf "$d"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
for dir in "$HOME/actions-runner/_work" "$HOME/.cache/setup-node" "$HOME/.npm/_cacache"; do
|
||||
if [ -d "$dir" ]; then
|
||||
find "$dir" -mindepth 1 -maxdepth 2 -mmin +1440 -exec rm -rf {} + 2>/dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# Wipe npm and setup-node caches (will repopulate from registry via cache: npm)
|
||||
rm -rf "$HOME/.npm/_cacache" "$HOME/.npm/_logs" 2>/dev/null
|
||||
rm -rf "$HOME/.cache/setup-node" 2>/dev/null
|
||||
|
||||
# Old actions-runner workspaces (>6h)
|
||||
if [ -d "$HOME/actions-runner/_work" ]; then
|
||||
find "$HOME/actions-runner/_work" -mindepth 1 -maxdepth 2 -mmin +360 -exec rm -rf {} + 2>/dev/null
|
||||
fi
|
||||
|
||||
# Docker aggressive prune (all dangling + unused, including volumes)
|
||||
if command -v docker >/dev/null 2>&1; then
|
||||
docker image prune -af --filter "until=24h" 2>/dev/null
|
||||
docker container prune -f --filter "until=24h" 2>/dev/null
|
||||
docker builder prune -af --filter "until=24h" 2>/dev/null
|
||||
docker system prune -af --volumes 2>/dev/null
|
||||
fi
|
||||
find /tmp -mindepth 1 -maxdepth 1 -mmin +120 \
|
||||
-not -name 'runner*' -not -name 'act*' \
|
||||
|
||||
# apt cache (if runner uses apt)
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
sudo apt-get clean 2>/dev/null
|
||||
fi
|
||||
if command -v yum >/dev/null 2>&1; then
|
||||
sudo yum clean all 2>/dev/null
|
||||
fi
|
||||
|
||||
# /tmp leftovers (>30 min) other than active runner state
|
||||
find /tmp -mindepth 1 -maxdepth 1 -mmin +30 \
|
||||
-not -name 'runner*' -not -name 'act*' -not -name 'tmp.*' \
|
||||
-exec rm -rf {} + 2>/dev/null
|
||||
|
||||
# journald logs vacuum to 100M
|
||||
if command -v journalctl >/dev/null 2>&1; then
|
||||
sudo journalctl --vacuum-size=100M 2>/dev/null
|
||||
fi
|
||||
|
||||
echo "=== Disk after cleanup ==="
|
||||
df -h
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user