mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-24 16:00:45 -06:00
65 lines
1.8 KiB
YAML
65 lines
1.8 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
|
|
|
|
sudo rm -rf \
|
|
/var/lib/docker/ \
|
|
"$AGENT_TOOLSDIRECTORY" \
|
|
/opt \
|
|
/usr/local/** &
|
|
|
|
# nix flake update wants to find git-core templates
|
|
# /usr/share/git-core/templates
|
|
# /usr/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
|