oizys/.github/actions/clean-disk/action.yml

65 lines
1.7 KiB
YAML
Raw Normal View History

2024-06-14 14:40:02 -05:00
name: 'Maximize build disk space'
description: 'Maximize the available disk space by removing unneeded software'
2024-06-14 15:02:01 -05:00
inputs:
purge-packages:
description: whether to remove apt packages
required: false
2024-06-24 13:28:32 -05:00
default: 'false'
2024-06-14 15:02:01 -05:00
apt-manifest-url:
description: url to apt-package manifest (default ubuntu-22.04.4)
required: false
default: 'https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.manifest'
2024-06-14 14:40:02 -05:00
runs:
using: "composite"
steps:
- name: Disk space report before modification
shell: bash
run: |
echo "==> Available space before cleanup"
echo
df -h
- name: Maximize build disk space
shell: bash
run: |
set -euo pipefail
2024-06-14 15:02:01 -05:00
non_manifest_packages() {
comm -2 -3 \
<(sudo apt-mark showmanual | sort) \
<(curl --silent "${{ inputs.apt-manifest-url }}" | grep --perl-regexp --only-matching '^[\w-.+]+' | sort)
}
2024-06-14 14:40:02 -05:00
echo "Removing unwanted software... "
2024-06-14 15:02:01 -05:00
if [[ "${{ inputs.purge-packages }}" == 'true' ]]; then
sudo apt-get purge \
--allow-remove-essential \
2024-06-19 12:26:00 -05:00
-qq \
2024-07-15 13:46:47 -05:00
$(non_manifest_packages) # > /dev/null
2024-06-14 15:02:01 -05:00
fi
2024-09-04 14:04:08 -05:00
(
GLOBIGNORE="/usr/share/git-core/**/*";
sudo rm -rf \
/var/lib/docker/ \
"$AGENT_TOOLSDIRECTORY" \
/opt \
/usr/{local,share}/**
) &
2024-09-04 13:52:02 -05:00
# {
# sudo swapoff -a
# sudo rm -f /mnt/swapfile
# } &
2024-06-14 15:02:01 -05:00
wait
2024-06-14 14:40:02 -05:00
echo "... done"
- name: Disk space report after modification
shell: bash
run: |
echo "==> Available space after cleanup"
echo
df -h