mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-08-21 06:47:17 -05:00
65 lines
1.7 KiB
YAML
65 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: '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'
|
|
|
|
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... "
|
|
|
|
sudo rm -rf /opt &
|
|
sudo rm -rf "$AGENT_TOOLSDIRECTORY" &
|
|
|
|
if [[ "${{ inputs.purge-packages }}" == 'true' ]]; then
|
|
sudo apt-get purge \
|
|
--allow-remove-essential \
|
|
-q \
|
|
$(non_manifest_packages) &
|
|
fi
|
|
|
|
wait
|
|
|
|
sudo rm -rf /var/lib/docker &
|
|
sudo rm -rf /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
|