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 \ # $(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