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
|
|
|
|
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-09-17 11:52:08 -05:00
|
|
|
shopt -s globstar
|
2024-06-14 14:40:02 -05:00
|
|
|
|
2024-06-14 15:02:01 -05:00
|
|
|
non_manifest_packages() {
|
|
|
|
comm -2 -3 \
|
2024-09-17 11:52:08 -05:00
|
|
|
<(sudo apt-mark showmanual | sort -u) \
|
|
|
|
<(grep --perl-regexp --only-matching '^[\w-.+]+' "${{ github.action_path }}"/ubuntu-24.04.1-live-server-amd64.manifest | sort -u)
|
2024-06-14 15:02:01 -05:00
|
|
|
}
|
|
|
|
|
2024-06-14 14:40:02 -05:00
|
|
|
echo "Removing unwanted software... "
|
2024-06-14 15:02:01 -05:00
|
|
|
|
2024-09-17 11:52:08 -05:00
|
|
|
if [[ "${{ inputs.purge-packages }}" == 'true' ]]; then
|
|
|
|
sudo apt-get purge \
|
|
|
|
--allow-remove-essential \
|
|
|
|
$(non_manifest_packages)
|
|
|
|
fi
|
|
|
|
|
2024-06-14 15:02:01 -05:00
|
|
|
|
2024-09-04 14:14:35 -05:00
|
|
|
sudo rm -rf \
|
|
|
|
/var/lib/docker/ \
|
|
|
|
"$AGENT_TOOLSDIRECTORY" \
|
|
|
|
/opt \
|
|
|
|
/usr/local/** &
|
|
|
|
|
2024-09-17 11:52:08 -05:00
|
|
|
find /usr/share -maxdepth -m -type d -not -name 'git-core' -delete
|
|
|
|
|
|
|
|
# for f in /usr/share/**/!(git-core); do
|
|
|
|
# sudo rm -rf $f &
|
|
|
|
# done
|
|
|
|
|
|
|
|
|
2024-09-04 14:14:35 -05:00
|
|
|
# nix flake update wants to find git-core templates
|
|
|
|
# /usr/share/git-core/templates
|
|
|
|
# /usr/share/**
|
|
|
|
{
|
|
|
|
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
|