mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-14 07:57:53 -06:00
64 lines
1.7 KiB
YAML
64 lines
1.7 KiB
YAML
name: 'Maximize build disk space'
|
|
description: 'Maximize the available disk space by removing unneeded software'
|
|
|
|
inputs:
|
|
purge-packages:
|
|
description: whether to remove apt packages
|
|
required: false
|
|
default: 'false'
|
|
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'
|
|
|
|
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
|
|
|
|
non_manifest_packages() {
|
|
comm -2 -3 \
|
|
<(sudo apt-mark showmanual | sort) \
|
|
<(curl --silent "${{ inputs.apt-manifest-url }}" | grep --perl-regexp --only-matching '^[\w-.+]+' | sort)
|
|
}
|
|
|
|
echo "Removing unwanted software... "
|
|
|
|
if [[ "${{ inputs.purge-packages }}" == 'true' ]]; then
|
|
sudo apt-get purge \
|
|
--allow-remove-essential \
|
|
-qq \
|
|
$(non_manifest_packages) # > /dev/null
|
|
fi
|
|
|
|
GLOBIGNORE="/usr/share/git-core/**/*"
|
|
sudo rm -rf \
|
|
/var/lib/docker/ \
|
|
"$AGENT_TOOLSDIRECTORY" \
|
|
/opt \
|
|
/usr/{local,share} &
|
|
|
|
{
|
|
sudo swapoff -a
|
|
sudo rm -f /mnt/swapfile
|
|
} &
|
|
|
|
wait
|
|
echo "... done"
|
|
|
|
- name: Disk space report after modification
|
|
shell: bash
|
|
run: |
|
|
echo "==> Available space after cleanup"
|
|
echo
|
|
df -h
|