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
|
|
|
|
default: 'true'
|
|
|
|
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
|
|
|
|
|
|
|
sudo rm -rf /opt &
|
|
|
|
sudo rm -rf "$AGENT_TOOLSDIRECTORY" &
|
|
|
|
|
|
|
|
if [[ "${{ inputs.purge-packages }}" == 'true' ]]; then
|
|
|
|
sudo apt-get purge \
|
|
|
|
--allow-remove-essential \
|
2024-06-19 12:26:00 -05:00
|
|
|
-qq \
|
2024-06-20 11:17:27 -05:00
|
|
|
$(non_manifest_packages) > /dev/null &
|
2024-06-14 15:02:01 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
wait
|
|
|
|
|
|
|
|
sudo rm -rf /var/lib/docker &
|
|
|
|
sudo rm -rf /usr/{local,share} &
|
|
|
|
{
|
|
|
|
sudo swapoff -a
|
|
|
|
sudo rm -f /mnt/swapfile
|
|
|
|
} &
|
|
|
|
|
|
|
|
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
|