.dotfiles/.github/actions/disk_space/action.yml
2025-07-04 21:47:56 -04:00

61 lines
1.4 KiB
YAML

name: "Clear disk space"
description: "Frees disk space in the GHA runner"
inputs:
debug:
description: Enabling this will print before and after disk sizes
default: false
required: false
paths:
description: List of paths to clear
required: false
default:
- /opt/microsoft
- /usr/share/dotnet
- /usr/share/swift
- /usr/lib/jvm
- /usr/local/.ghcup
- /home/runner/.rustup
- /usr/local/share/chromium
- /usr/local/lib/android
- /opt/ghc
- /opt/hostedtoolcache
- /usr/lib/llvm-18
runs:
using: "composite"
steps:
- name: Get disk usage
shell: bash
run: |
# df -h | head -n 1 | cut -d ' ' -f 3,5
# df -h | grep /\$ | cut -d ' ' -f 3,5
df -h
- name: Detailed usage
shell: bash
run: |
du -h -d3 / 2>/dev/null | sort -hr | head -n 20 || true
- name: Clear
shell: bash
run: |
SAVEIFS=$IFS
IFS=$'\n'
paths=${{ inputs.paths }}
IFS=$SAVEIFS
sudo rm -rf $paths
sudo docker system prune -af || true
sudo docker image prune -af || true
sudo docker builder prune -af || true
- name: Get disk usage
shell: bash
run: |
echo "used use%"
# df -h | grep /\$ | cut -d ' ' -f 5,9
df -h
- name: Detailed usage
shell: bash
run: |
du -h -d3 / 2>/dev/null | sort -hr | head -n 20 || true