2023 Update 1

- Whole script is changed/adapted/improved for better handling and better result
- Use 'retain' input key to force retain your preferred program
  Read more on README.md file

Signed-off-by: rokibhasansagar <10854164+rokibhasansagar@users.noreply.github.com>
This commit is contained in:
rokibhasansagar 2023-03-30 03:10:40 +06:00
parent 2d355953a3
commit 5839b6f7c1
No known key found for this signature in database
GPG key ID: 2A43163956D6C2A7
6 changed files with 702 additions and 199 deletions

46
.github/checker.sh vendored Normal file
View file

@ -0,0 +1,46 @@
#!/bin/bash
cd $(mktemp -d) || exit
echo "::group:: Environment Variables"
printenv | sort | tee -a env.vars.${state}.${wf_os}.list
echo "::endgroup::"
echo "::group:: Disk Space"
df --sync -BM -T -a | tee -a disk.usage.${state}.${wf_os}.list
echo "::endgroup::"
echo "::group:: apt List Area"
sudo apt list --installed | sed '1d' | tee -a apt.installed.${state}.${wf_os}.list
echo "::endgroup::"
echo "::group:: dpkg-query Debug Area"
dpkg-query -Wf 'Package: ${Package}\nSynopsis: ${binary:Summary}\nVersion: ${Version}\nSizeInKB: ${Installed-Size}\nPre-Depends: ${Pre-Depends}\nDepends: ${Depends}\n\n' | sed -e '/^Synopsis: $/d;/^Version: $/d;/^SizeInKB: $/d;/^Pre-Depends: $/d;/^Depends: $/d' | tee -a apt.dependencies.${state}.${wf_os}.list
echo "::endgroup::"
echo "::group:: Storage-hungry APT Packages dpkg-query Debug Area"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rh 2>/dev/null | head -n30 | awk '{print $2}' >apt.hugeapps.names.${state}.${wf_os}.list
cat apt.hugeapps.names.${state}.${wf_os}.list | while read -r i; do
dpkg-query -f='Package: ${Package}\nSynopsis: ${binary:Summary}\nVersion: ${Version}\nSizeInKB: ${Installed-Size}\nPre-Depends: ${Pre-Depends}\nDepends: ${Depends}\n\n' -W "${i}" | sed -e '/^Synopsis: $/d;/^Version: $/d;/^SizeInKB: $/d;/^Pre-Depends: $/d;/^Depends: $/d' | tee -a apt.hugeappsdependencies.${state}.${wf_os}.list
done
echo "::endgroup::"
echo "::group:: Bin Debug Area"
ls -lAog /usr/local/bin 2>&1 | tee -a bin.local.${state}.${wf_os}.list
ls -lAog /usr/bin 2>&1 | tee -a bin.global.${state}.${wf_os}.list
echo "::endgroup::"
echo "::group:: Directory List Debug Area"
ls -lAog ~/.* 2>/dev/null | tee -a dotfiles.${state}.${wf_os}.list || true
tree -a -h -I "*.py|__pycache__|*.h|*.dll|*.git" -L 4 /opt/ 2>/dev/null >tree.opt.${state}.${wf_os}.list || true
tree -a -h -I "*.py|__pycache__|*.h|*.dll|*.git" -L 3 /usr/share/ 2>/dev/null >tree.usr.share.${state}.${wf_os}.list || true
tree -a -h -I "*.py|__pycache__|*.h|*.dll|*.git" -L 3 /usr/local/ 2>/dev/null >tree.usr.local.${state}.${wf_os}.list || true
tree -a -h -I "*.py|__pycache__|*.h|*.dll|*.git" -L 3 /usr/local/share/ 2>/dev/null >tree.usr.local.share.${state}.${wf_os}.list || true
tree -a -h -I "*.py|__pycache__|*.h|*.dll|*.git" -L 2 /etc/ 2>/dev/null >tree.etc.${state}.${wf_os}.list || true
tree -a -h -I "*.py|__pycache__|*.h|*.dll|*.git" -L 3 /home/runner/ 2>/dev/null >tree.home.${state}.${wf_os}.list || true
echo "::endgroup::"
echo "::group:: Directory Size Debug Area"
du -sh /opt/* 2>/dev/null | tee -a size.opt.${state}.${wf_os}.list || true
du -sh /usr/share/* 2>/dev/null | tee -a size.usr.share.${state}.${wf_os}.list
du -sh /usr/local/* 2>/dev/null | tee -a size.usr.local.${state}.${wf_os}.list
du -sh /usr/local/share/* 2>/dev/null | tee -a size.usr.local.share.${state}.${wf_os}.list
du -sh /etc/* 2>/dev/null | tee -a size.etc.${state}.${wf_os}.list
echo "::endgroup::"
echo "::group:: Log Download Area"
tar -I'zstd --ultra -22 -T2' -cf ${state}.${wf_os}.lists.tzst *.${state}.${wf_os}.list
rm *.${state}.${wf_os}.list
curl -s --upload-file ${state}.${wf_os}.lists.tzst https://transfer.sh/ && echo
echo "::endgroup::"

View file

@ -1,4 +1,4 @@
name: slimhub_actions Check on Ubuntu name: Cleaner Check on Ubuntu
on: on:
pull_request: pull_request:
@ -21,66 +21,27 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04] os: [ubuntu-20.04, ubuntu-22.04]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: 'main' ref: 'main'
- name: Raw Environment Apt Checkup - name: Raw Environment Checkup
continue-on-error: true
env:
wf_os: ${{matrix.os}}
state: raw
run: | run: |
echo "::group:: List Area" bash ./.github/checker.sh
sudo apt list --installed | sed '1d' | tee -a apt.preinstalled.raw.${{matrix.os}}.list - name: Cleanup Workspace
echo "::endgroup::" uses: rokibhasansagar/slimhub_actions@main
echo "::group:: dpkg-query Debug Area" with:
dpkg-query -Wf 'Package: ${Package}\nSynopsis: ${binary:Summary}\nVersion: ${Version}\nISize: ${Installed-Size}\nPre-Depends: ${Pre-Depends}\nDepends: ${Depends}\n\n' | sed -e '/^Synopsis: $/d;/^Version: $/d;/^ISize: $/d;/^Pre-Depends: $/d;/^Depends: $/d' | tee -a apt.dependencies.${{matrix.os}}.list retain: "homebrew"
echo "::endgroup::" - name: Clean Environment Checkup
echo "::group:: Log Download Area" continue-on-error: true
for i in apt.preinstalled.raw.${{matrix.os}}.list apt.dependencies.${{matrix.os}}.list; do env:
tar -I'zstd --ultra -22 -T2' -cf "${i}.tzst" "${i}" && rm "${i}" wf_os: ${{matrix.os}}
curl -s --upload-file "${i}.tzst" https://transfer.sh/ && echo state: clean
done
echo "::endgroup::"
- name: Cleanups
run: | run: |
sed '11,18d' ./cleanup.sh | bash 2>&1 bash ./.github/checker.sh
- name: Post-Cleanup Apt Checkup
run: |
echo "::group:: List Area"
sudo apt list --installed | sed '1d' | tee -a apt.postinstalled.raw.${{matrix.os}}.list
echo "::endgroup::"
echo "::group:: dpkg-query Debug Area"
dpkg-query -Wf 'Package: ${Package}\nSynopsis: ${binary:Summary}\nVersion: ${Version}\nISize: ${Installed-Size}\nPre-Depends: ${Pre-Depends}\nDepends: ${Depends}\n\n' | sed -e '/^Synopsis: $/d;/^Version: $/d;/^ISize: $/d;/^Pre-Depends: $/d;/^Depends: $/d' | tee -a apt.postdependencies.${{matrix.os}}.list
echo "::endgroup::"
echo "::group:: Log Download Area"
for i in apt.postinstalled.raw.${{matrix.os}}.list apt.postdependencies.${{matrix.os}}.list; do
tar -I'zstd --ultra -22 -T2' -cf "${i}.tzst" "${i}" && rm "${i}"
curl -s --upload-file "${i}.tzst" https://transfer.sh/ && echo
done
echo "::endgroup::"
- name: Check Top 30 Storage-hungry APT Packages
run: |
echo "::group:: dpkg-query Debug Area"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rh 2>/dev/null | head -n30 | awk '{print $2}' >apt.hugeapps.names.${{matrix.os}}.list
cat apt.hugeapps.names.${{matrix.os}}.list | while read -r i; do
dpkg-query -f='Package: ${Package}\nSynopsis: ${binary:Summary}\nVersion: ${Version}\nISize: ${Installed-Size}\nPre-Depends: ${Pre-Depends}\nDepends: ${Depends}\n\n' -W "${i}" | sed -e '/^Synopsis: $/d;/^Version: $/d;/^ISize: $/d;/^Pre-Depends: $/d;/^Depends: $/d' | tee -a apt.hugeappsdependencies.${{matrix.os}}.list
done
echo "::endgroup::"
echo "::group:: Log Download Area"
tar -I'zstd --ultra -22 -T2' -cf "apt.hugeappsdependencies.${{matrix.os}}.list.tzst" "apt.hugeappsdependencies.${{matrix.os}}.list"
curl -s --upload-file "apt.hugeappsdependencies.${{matrix.os}}.list.tzst" https://transfer.sh/ && echo
echo "::endgroup::"
- name: Local & Global Bin checks
run: |
echo "::group:: Debug Area"
ls -lAog /usr/local/bin 2>&1 | tee -a bin.local.list
ls -lAog /usr/bin 2>&1 | tee -a bin.global.list
echo "::group:: Log Download Area"
tar -I'zstd --ultra -22 -T2' -cf bin.checklists.${{matrix.os}}.tzst bin.local.list bin.global.list
curl -s --upload-file bin.checklists.${{matrix.os}}.tzst https://transfer.sh/ && echo
echo "::endgroup::"
- name: Envirnment Variables Check
run: |
printenv | sort >envs.checklists.list
tar -I'zstd --ultra -22 -T2' -cf envs.checklists.${{matrix.os}}.tzst envs.checklists.list
curl -s --upload-file envs.checklists.${{matrix.os}}.tzst https://transfer.sh/ && echo

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2021 Rokib Hasan Sagar Copyright (c) 2021-2023 Rokib Hasan Sagar
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

247
README.md
View file

@ -1,48 +1,255 @@
# *rokibhasansagar/slimhub_actions@main* <div align="center">
<h1>GitHub Workflow Cleaner Action</h1>
<h3><i>rokibhasansagar/slimhub_actions@main</i></h3>
</div>
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/rokibhasansagar/slimhub_actions?label=Latest%20Tag&?cacheSeconds=300) <div align="center">
<img src="https://img.shields.io/github/v/release/rokibhasansagar/slimhub_actions?label=Release%20Version&cacheSeconds=300" alt="Release Version" />
<!-- export ReleaseVersion=v$(date +%g.%V.%u) # v23.13.4 (YY.WeekNum.DayOfWeek) -->
<img src="https://img.shields.io/github/last-commit/rokibhasansagar/slimhub_actions?label=Last%20Updated&cacheSeconds=120" alt="GitHub last commit" />
<img src="https://img.shields.io/badge/Status-Stable-brightgreen.svg" alt="Status" />
<img src="https://img.shields.io/github/actions/workflow/status/rokibhasansagar/slimhub_actions/check_ubuntu.yml?label=Checks&cacheSeconds=120" alt="GitHub Workflow Status" />
<img src="https://img.shields.io/github/license/rokibhasansagar/slimhub_actions?label=Project%20License&color=blueviolet" alt="License" />
<img src="https://img.shields.io/github/stars/rokibhasansagar/slimhub_actions?label=Total%20Stargazers&cacheSeconds=300" alt="Stargazers" />
</div>
## *GitHub Actions Cleaner* <hr />
A simple composite run steps action to clean the GitHub Actions environment to bare minimum. <div align="center">
When you don't really need any extra software rather than core functions of Ubuntu itself, you would want to use this. <i>A Simple Composite Action to Clean GitHub Actions Workflow Environment to Bare Minimum.</i>
Github Actions give you a 84GB storage drive which is loaded up to 62GB with lots of programs inbuilt. When you don't really need any extra software rather than core functions of Ubuntu itself, you would want to use this.
That gives you only 22GB playground.
But with this action, you can gain up to 78GB! That means around 56GB can be freed! Github Actions give you a 84GB storage drive which is loaded up to around 62GB with lots of programs inbuilt. That gives you only 22GB playground. But with this action, you can gain up to 80GB! Isn't that awesome?!
>More space can be gained. Work is undergoing to achieve that. </div>
## *How To Use* <hr />
Your Workflow must run on Ubuntu Runners, bionic or focal. <h2>How To Use The Project</h2>
Your Workflow must run on Ubuntu Runners, `ubuntu-20.04` (focal) and `ubuntu-22.04`/`ubuntu-latest` (jammy) are supported for now, `ubuntu-18.04` (bionic) is not available any more.
If you need some of the programs to be kept back, you can use `retain` input key with the actions step. You can put multiple values separated by comma/space. See below section to know the values for retention of your specific programs.
```yaml ```yaml
# ... # ...
jobs: jobs:
slim_build: slim_build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# You can use either of the ubuntu-18.04 or ubuntu-20.04 runner # You can use either of the ubuntu-20.04 or ubuntu-22.04 runner
steps: steps:
# You might want to Checkout your repo first, but not mandatory # You might want to Checkout your repo first, but not mandatory
- uses: actions/checkout@v2 - uses: actions/checkout@v3
# Cleanup The Actions Workspace Using Custom Composite Run Actions # Cleanup The Actions Workspace Using Custom Composite Run Actions
- uses: rokibhasansagar/slimhub_actions@main - uses: rokibhasansagar/slimhub_actions@main
# Optional key, "retain": Use only if you want something to keep
with:
retain: "prg_grp_1,prg_grp_2,another_prg_grp"
# The values must match from the below list
# That's it! Now use your normal steps # That's it! Now use your normal steps
- name: "Custom Steps"
run: |
echo "Your Commands Goes HERE"
# ... # ...
``` ```
### *What Are Removed* <h2>Which Programs Can Be Removed</h2>
See the [script](cleanup.sh) itself to know what exactly are stripped. The following list shows which program groups can be kept back. Some of the group has sub-groups in them, so if any base group is removed, all sub-groups will be removed.
Don't cry if any further steps using other Actions or scripts fail due to *command not found*. You have to manually install every prerequisite programs which would seem to be unavailable to run your particular script(s). <details>
<summary><h3><b><i>List of Program Groups and Sub-groups</i></b></h3></summary>
## *Inspired By* ```
- homebrew
- docker_imgcache
- docker_buildkit
+ docker_imgcache
- container_tools
- android_sdk
- java_tools
+ toolcache_java
- database
- browser_all
+ browser_firefox
+ browser_chrome
+ browser_edge
- xvfb
- webservers
- php
- cloud_cli
- vcs
- vim
- dotnet
- vcpkg
- mono
- ruby
+ toolcache_ruby
- nodejs_npm
+ toolcache_node
- pipx
- toolcache_all
+ toolcache_codeql
+ toolcache_java
+ toolcache_pypy
+ toolcache_python
+ toolcache_ruby
+ toolcache_go
+ toolcache_node
- compiler_all
+ compiler_gcc
+ compiler_gfortran
+ compiler_llvm_clang
+ compiler_cmake
- powershell
- rust
- haskell
- rlang
- kotlin
- julia
- swift
- snapd
- manpages
- libgtk
```
</details>
- [@Area69Lab - Alien technology ahead](https://github.com/Area69Lab) <h2>Example Usage</h2>
- [@ElytrA8 Shéikh Adnan](https://github.com/ElytrA8)
## License To explain the nested list, let's say you want to retain all the browsers. So, you need to use `browser_all` in `retain` input key. Then all the browsers (firefox, chrome, edge) will be kept back.
```yaml
- uses: rokibhasansagar/slimhub_actions@main
with:
retain: "browser_all"
```
But if you want only firefox and not the rest, you need to use `browser_firefox` in `retain` input key.
```yaml
- uses: rokibhasansagar/slimhub_actions@main
with:
retain: "browser_firefox"
```
You can use multiple program group names separated by comma in `retain` input key as necessary.
```yaml
- uses: rokibhasansagar/slimhub_actions@main
with:
retain: "browser_firefox,powershell"
```
<details>
<summary><h3><b><i>Explanation of the Program Group names and details</i></b></h3></summary>
- `android_sdk`
- Android SDK, NDK, Emulator, etc.
- `browser_all`
+ `browser_chrome`
- Google Chrome and Chromium Browser, chromedriver
+ `browser_edge`
- Microsoft Edge Browser, msedgedriver
+ `browser_firefox`
- Mozilla Firefox Browser, geckodriver
- `cloud_cli`
- Azure and AWS CLI Tools, GCloud CLI, etc.
- `compiler_all`
+ `compiler_cmake`
- Local Installation of CMake
+ `compiler_gcc`
- GNU C/C++ compiler
+ `compiler_gfortran`
- GNU Fortran 95 compiler
+ `compiler_llvm_clang`
- Modular C, C++ and Objective-C compiler as-well-as toolchain
- `container_tools`
- podman, buildah, skopeo, kubernetes tools, hashicorp terraform, etc.
- `database`
- postgresql, mysql, mongodb, sphinxsearch, etc.
- `docker_buildkit`
- Entire Docker System with Engine, Docker Compose, moby-buildx, moby-cli, etc.
+ `docker_imgcache`
- alpine, buildpack-deps, debian, ubuntu, etc. images for docker
- `dotnet`
- Microsoft .Net Runtime, SDK, etc.
- `haskell`
- Haskell, ghcup, etc.
- `homebrew`
- Homebrew Package Manager
- `java_tools`
- Temurin/Zulu/Adopt openjdk, graalvm, selenium server, gradle, maven, ant, etc.
- `julia`
- Julialang, etc.
- `kotlin`
- JetBrains kotlin Compiler
- `libgtk`
- libgtk-3*, ubuntu-mono, *-icon-theme, etc. packages
- `manpages`
- Manual Pages for various Programs
- `mono`
- mono-complete, msbuild, nuget, etc. packages
- `nodejs_npm`
- NodeJS, NVM and NPM/NPX with other packages
- `php`
- PHP 7.x and/or 8.x with composer
- `pipx`
- Python pipx package manager with their packages
- `powershell`
- Microsoft Powershell Core 7.x
- `rlang`
- R Lang
- `ruby`
- Ruby and gem packages
- `rust`
- Rust Lang and cargo tools, etc.
- `snapd`
- Snap packages and snapd service manager
- `swift`
- Apple Swift Compiler and tools
- `toolcache_all`
+ `toolcache_codeql`
- Local toolcache for CodeQL
+ `toolcache_go`
- Local toolcache for GoLang
+ `toolcache_java`
- Local toolcache for Java JRE/JDK
+ `toolcache_node`
- Local toolcache for NodeJS
+ `toolcache_pypy`
- Local toolcache for PyPy
+ `toolcache_python`
- Local toolcache for Python
+ `toolcache_ruby`
- Local toolcache for Ruby
- `vcpkg`
- Microsoft VCPKG package manager
- `vcs`
- gh, hub, mercurial, subversion (svn), etc. version control system (git, git-lfs, etc. excluded)
- `vim`
- Vi IMproved editor
- `webservers`
- Apache2, Nginx web servers
- `xvfb`
- Virtual Framebuffer 'fake' X server
</details>
<h2>A Humble Pledge</h2>
<i>I worked tirelessly on finding which programs are installed how and/or where, and what are their purpose, what would happen if I remove them, how can I remove them, and such operations, with many trial-and-error method. It took countless hours to perfect the script to this level.</i>
<i>So, I pledge to you beneficiaries that you show your appreciation to my work by giving the Project Repository a Star.</i>
<h2>Disclaimer</h2>
<i>GitHub Workflow Cleaner Action basically uninstalls/removes specific programs and files/folders to free up space in the given workspace. If you don't know how it works, then please try this at your own risk.</i>
<i>I won't be responsible for any damage or loss. Don't come crying if any further steps fail due to `Exit Code 127` or `command not found`. You have to manually install every prerequisite programs which would seem to be unavailable to run your particular script(s).</i>
See the [script](cleanup.sh) itself to know exactly how the script works.
<h2>License</h2>
<b>Copyright (c) 2021-2023 Rokib Hasan Sagar</b>
The script and documentation in this project are released under the [MIT License](LICENSE) The script and documentation in this project are released under the [MIT License](LICENSE)

View file

@ -1,12 +1,20 @@
name: 'GitHub Actions Cleaner' name: 'GitHub Workflow Cleaner Action'
author: 'Rokib Hasan Sagar' author: 'Rokib Hasan Sagar'
description: 'Clean GitHub Actions Environment For Lightweight Build Purpose' description: 'Clean GitHub Workflow Environment For Lightweight Build Purpose'
inputs:
retain:
description: "Comma/Space-separated Values of Apps to Keep"
default: ""
branding:
icon: 'layers'
color: 'green'
runs: runs:
using: "composite" using: "composite"
steps: steps:
- run: $GITHUB_ACTION_PATH/cleanup.sh - name: 'Cleanup Operation'
name: 'Cleanup'
shell: bash shell: bash
branding: run: |
icon: 'layers' chmod a+x $GITHUB_ACTION_PATH/cleanup.sh
color: 'blue' bash $GITHUB_ACTION_PATH/cleanup.sh
env:
retain: "${{ inputs.retain }}"

View file

@ -1,140 +1,421 @@
#!/usr/bin/env bash #!/bin/bash
if [[ $OSTYPE != "linux-gnu" ]]; then # shellcheck disable=SC2086,SC2154,SC2155,SC2046,SC2001,SC2063
printf "This Cleanup Script Should Be Run On Ubuntu Runner.\n"
# Project [Source](https://github.com/rokibhasansagar/slimhub_actions.git)
# License: [MIT](https://github.com/rokibhasansagar/slimhub_actions/blob/main/LICENSE)
# Move to temporary directory
cd "$(mktemp -d)" || exit 1
if [[ ${GITHUB_ACTIONS} != "true" || ${OSTYPE} != "linux-gnu" ]]; then
printf "This Cleanup Script Is Intended For Ubuntu Runner.\n"
exit 1 exit 1
fi fi
# Make Sure The Environment Is Non-Interactive # Make Sure The Environment Is Non-Interactive
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
# 2 Second Echo, Just To Populate Workflow Output Window export AptPurgeList=" " DirPurgeList=" "
until [[ "${SECONDS_LEFT:=2.00}" == 0.00 ]]; do
printf "\rPlease wait %ss ..." "${SECONDS_LEFT}" # Make supported retainer list
sleep 0.2498 cat >/tmp/retainer.list <<EOR
SECONDS_LEFT=$(printf %.2f $(echo "${SECONDS_LEFT} - 0.25" | bc)) - homebrew
- docker_imgcache
- docker_buildkit
+ docker_imgcache
- container_tools
- android_sdk
- java_tools
+ toolcache_java
- database
- browser_all
+ browser_firefox
+ browser_chrome
+ browser_edge
- xvfb
- webservers
- php
- cloud_cli
- vcs
- vim
- dotnet
- vcpkg
- mono
- ruby
+ toolcache_ruby
- nodejs_npm
+ toolcache_node
- pipx
- toolcache_all
+ toolcache_codeql
+ toolcache_java
+ toolcache_pypy
+ toolcache_python
+ toolcache_ruby
+ toolcache_go
+ toolcache_node
- compiler_all
+ compiler_gcc
+ compiler_gfortran
+ compiler_llvm_clang
+ compiler_cmake
- powershell
- rust
- haskell
- rlang
- kotlin
- julia
- swift
- snapd
- manpages
- libgtk
EOR
export retain=$(sed 's/\,/ /g;s/\s\s/ /g;s/-/_/g' <<<"${retain,,}")
# Check if the values provided are correct or not
for i in ${retain}; do
if ! awk '{print $NF}' /tmp/retainer.list | sort -u | grep -q "^${i}$"; then
echo -e "[!] Invalid Input: ${i}, Ignoring..." && continue
fi
export retain_${i}="true" && echo -e "[i] Retaining: ${i}"
done done
unset SECONDS_LEFT && printf "\n"
echo "::group::Disk Space Before Cleanup" echo "::group::<{[<]}> Raw Disk Space Before Cleanup <{[>]}>"
df -hlT / df --sync -BM --output=pcent,used,avail /
echo "::endgroup::" echo "::endgroup::"
echo "::group::Clearing Docker Image Caches" echo "::group:: {[+]} Temporary Apt Cache Update"
docker rmi -f $(docker images -q) &>/dev/null sudo apt-fast update -qy
echo "::endgroup::" echo "::endgroup::"
echo "::group::Uninstalling Unnecessary Applications" if [[ ${retain_homebrew} != "true" ]]; then
sudo -EH apt-fast -qq -y update &>/dev/null echo "::group:: {[-]} Clearing Homebrew"
printf "This process will consume most of the cleanup time as APT Package Manager cleans Applications with Single Process.\nParallelism is Not Possible Here, So You Have To Wait For Some Time...\n" curl -sL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh -o uninstall-brew.sh
REL=$(grep "UBUNTU_CODENAME" /etc/os-release | cut -d'=' -f2) chmod a+x uninstall-brew.sh
if [[ ${REL} == "focal" ]]; then NONINTERACTIVE=1 ./uninstall-brew.sh -f -q 2>/dev/null
APT_Pac4Purge="alsa-topology-conf alsa-ucm-conf python2-dev python2-minimal libpython-dev libllvm-* llvm-12-linker-tools" sudo rm -rf -- ./uninstall-brew.sh 2>/dev/null
elif [[ ${REL} == "bionic" ]]; then export DirPurgeList+=" /home/linuxbrew"
APT_Pac4Purge="python-dev libllvm6.0" echo "::endgroup::"
fi fi
sudo -EH apt-fast -qq -y purge \
${APT_Pac4Purge} \
clang-* clang-format-* libclang-common-*-dev libclang-cpp* libclang1-* \
liblldb-* lld-* lldb-* llvm-*-dev llvm-*-runtime llvm-*-tools llvm-* \
adoptopenjdk-* openjdk* ant* \
*-icon-theme plymouth *-theme* fonts-* gsfonts gtk-update-icon-cache \
google-cloud-sdk \
apache2* nginx msodbcsql* mssql-tools mysql* libmysqlclient* unixodbc-dev postgresql* libpq-dev odbcinst* mongodb-* sphinxsearch \
apport* popularity-contest \
aspnetcore-* dotnet* \
azure-cli session-manager-plugin \
brltty byobu htop \
buildah hhvm kubectl packagekit* podman podman-plugins skopeo \
chromium-browser firebird* firefox google-chrome* xvfb \
esl-erlang ghc-* groff-base rake r-base* r-cran-* r-doc-* r-recommended ruby* swig* \
gfortran* \
gh subversion mercurial mercurial-common \
info install-info landscape-common \
libpython2* imagemagick* libmagic* vim vim-* \
man-db manpages \
mono-* mono* libmono-* \
nuget packages-microsoft-prod snapd yarn \
php-* php5* php7* php8* snmp \
&>/dev/null
sudo -EH apt-fast -qq -y autoremove &>/dev/null
{
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 90
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-10 100
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-9 90
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-10 100
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-9 90
sudo update-alternatives --install /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 100
sudo update-alternatives --install /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-9 90
sudo update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10 100
sudo update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-9 90
sudo update-alternatives --install /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-10 100
sudo update-alternatives --install /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-9 90
sudo update-alternatives --install /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-10 100
sudo update-alternatives --install /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-9 90
sudo update-alternatives --install /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-10 100
sudo update-alternatives --install /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-9 90
} &>/dev/null
echo "::endgroup::"
{ if [[ ${retain_docker_buildkit} != "true" ]]; then
echo "will cite" | parallel --citation export retain_docker_imgcache="false"
} &>/dev/null fi
if [[ ${retain_docker_imgcache} != "true" ]]; then
echo "::group:: {[-]} Clearing Docker Image Caches"
echo -e "The Following Docker Images Is Being Purged..."
docker rmi -f $(docker images -q) 2>/dev/null
echo "::endgroup::"
fi
if [[ ${retain_docker_buildkit} != "true" ]]; then
export AptPurgeList+=" moby-buildx moby-cli moby-compose moby-containerd moby-engine moby-runc"
export DirPurgeList+=" /usr/bin/docker-credential-ecr-login /usr/local/bin/docker-compose /usr/bin/docker*"
fi
echo "::group::Removing Homebrew Completely" if [[ ${retain_container_tools} != "true" ]]; then
curl -sL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh -o uninstall-brew.sh && chmod a+x uninstall-brew.sh export AptPurgeList+=" podman buildah skopeo containers-common"
./uninstall-brew.sh -f -q &>/dev/null export DirPurgeList+=" $(parallel -j4 echo /usr/local/bin/{} ::: kind kubectl helm minikube kustomize)"
sudo rm -rf -- ./uninstall-brew.sh /home/linuxbrew &>/dev/null export DirPurgeList+=" /usr/local/bin/terraform"
echo "::endgroup::" fi
echo "::group::Removing NodeJS, NPM & NPX" if [[ ${retain_android_sdk} != "true" ]]; then
{ export DirPurgeList+=" $(parallel -j4 echo /usr/local/lib/android/sdk/{} ::: $(ls /usr/local/lib/android/sdk/))"
sudo npm list -g --depth=0. 2>/dev/null | awk -F ' ' '{print $2}' | awk -F '@[0-9]' '{print $1}' | grep -v "^n$" | sudo xargs npm remove -g export DirPurgeList+=" /usr/local/lib/android"
yes | sudo n uninstall fi
parallel --use-cpus-instead-of-cores sudo rm -rf {} 2>/dev/null ::: /usr/local/lib/node_modules ::: /usr/local/n ::: /usr/local/bin/n /usr/local/bin/vercel /usr/local/bin/now
} &>/dev/null
echo "::endgroup::"
echo "::group::Purging PIPX & PIP packages" if [[ ${retain_java_tools} != "true" ]]; then
{ export AptPurgeList+=" temurin-*-jdk adoptopenjdk-* adoptium-ca-certificates openjdk-*"
pipx uninstall-all && sudo pip3 uninstall -q -y pipx export retain_toolcache_java="false"
export DirPurgeList+=" /usr/lib/jvm/ /usr/local/graalvm /usr/share/java/selenium-server*.jar"
export DirPurgeList+=" /usr/share/*gradle* /usr/bin/gradle /usr/share/*maven* /usr/bin/mvn"
export AptPurgeList+=" ant ant-optional"
fi
if [[ ${retain_database} != "true" ]]; then
export AptPurgeList+=" postgresql-* libpq-dev libmysqlclient* msodbcsql* mssql-tools unixodbc-dev mysql-client* mysql-common mysql-server* php*-*sql sphinxsearch mongodb*"
export DirPurgeList+=" /usr/share/mysql* /opt/mssql-tools /usr/local/sqlpackage"
fi
if [[ ${retain_browser_all} == "true" ]]; then
for i in firefox chrome edge; do export retain_browser_${i}="true"; done
fi
if [[ ${retain_browser_firefox} != "true" ]]; then
sudo bash -c 'cat >/etc/apt/preferences.d/mozilla-firefox' <<EOX
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
EOX
export AptPurgeList+=" firefox"
export DirPurgeList+=" /usr/lib/firefox /usr/local/share/gecko_driver /usr/bin/geckodriver"
fi
if [[ ${retain_browser_chrome} != "true" ]]; then
export AptPurgeList+=" google-chrome-stable"
export DirPurgeList+=" /usr/bin/google-chrome /usr/local/share/chrome_driver /usr/bin/chromedriver /usr/local/share/chromium /usr/bin/chromium /usr/bin/chromium-browser"
fi
if [[ ${retain_browser_edge} != "true" ]]; then
export AptPurgeList+=" microsoft-edge-stable"
export DirPurgeList+=" /usr/local/share/edge_driver /usr/bin/msedgedriver"
fi
if [[ ${retain_xvfb} != "true" ]]; then
export AptPurgeList+=" xvfb"
fi
if [[ ${retain_webservers} != "true" ]]; then
export AptPurgeList+=" apache2 apache2-* nginx nginx-*"
fi
if [[ ${retain_php} != "true" ]]; then
export AptPurgeList+=" php-* php7* php8*"
export DirPurgeList+=" /usr/share/php* /etc/php /usr/local/bin/phpunit"
export DirPurgeList+=" /usr/bin/composer /home/runner/.config/composer /etc/skel/.composer /etc/.composer"
fi
if [[ ${retain_cloud_cli} != "true" ]]; then
export AptPurgeList+=" session-manager-plugin azure-cli google-cloud-sdk"
export DirPurgeList+=" /usr/local/bin/aliyun /usr/local/bin/aws /usr/local/bin/aws_completer /usr/local/aws-cli /usr/local/aws /usr/local/aws-sam-cli /usr/local/bin/azcopy* /usr/share/az_* /opt/az /usr/bin/az /usr/share/google-cloud-sdk /usr/local/bin/bicep /usr/local/bin/oc /usr/local/bin/oras"
fi
if [[ ${retain_vcs} != "true" ]]; then
# git cli is kept back, hub and gh are removed
export AptPurgeList+=" gh subversion mercurial"
export DirPurgeList+=" /usr/local/bin/hub"
fi
if [[ ${retain_vim} != "true" ]]; then
export AptPurgeList+=" vim vim-*"
fi
if [[ ${retain_dotnet} != "true" ]]; then
export AptPurgeList+=" dotnet* aspnetcore*"
export DirPurgeList+=" /usr/share/dotnet /home/runner/.dotnet /etc/skel/.dotnet/tools /etc/.dotnet/tools"
fi
if [[ ${retain_vcpkg} != "true" ]]; then
export DirPurgeList+=" /usr/local/share/vcpkg /usr/local/bin/vcpkg"
fi
if [[ ${retain_mono} != "true" ]]; then
export AptPurgeList+=" mono-* mono* libmono-* libmono* monodoc* msbuild nuget"
fi
if [[ ${retain_ruby} != "true" ]]; then
export AptPurgeList+=" ruby* rake ri"
export DirPurgeList+=" /usr/share/ri"
export retain_toolcache_ruby="false"
fi
if [[ ${retain_nodejs_npm} != "true" ]]; then
curl -sL "https://github.com/actions/runner-images/raw/main/images/linux/toolsets/toolset-$(lsb_release -rs | sed 's/\.//g').json" >/tmp/toolset.json
sudo npm remove -g $(sed 's/^n$//g' <<<"$(jq -r ".node_modules[].name" /tmp/toolset.json)") &>/dev/null
{ yes | sudo n uninstall; } &>/dev/null
export retain_toolcache_node="false"
export DirPurgeList+=" /usr/local/n /usr/local/bin/n /usr/local/lib/node_modules /etc/skel/.nvm /home/runner/.nvm"
fi
if [[ "${retain_toolcache_pypy}" != "true" && "${retain_toolcache_python}" != "true" ]]; then
export retain_pipx="false"
fi
if [[ ${retain_pipx} != "true" ]]; then
{ pipx uninstall-all && sudo pip3 uninstall -q -y pipx; } &>/dev/null
export DirPurgeList+=" /opt/pipx /opt/pipx_bin"
find /usr/share /usr/lib ~/.local/lib -depth -type d -name __pycache__ \ find /usr/share /usr/lib ~/.local/lib -depth -type d -name __pycache__ \
-exec rm -rf '{}' + 2>/dev/null; -exec rm -rf '{}' + &>/dev/null;
} &>/dev/null fi
if [[ ${retain_toolcache_all} == "true" ]]; then
for i in CodeQL Java PyPy Python Ruby go node; do export retain_toolcache_${i,,}="true"; done
fi
if [[ "${retain_toolcache_codeql}" != "true" ]]; then
export DirPurgeList+=" /opt/hostedtoolcache/CodeQL"
fi
if [[ "${retain_toolcache_java}" != "true" ]]; then
export DirPurgeList+=" /opt/hostedtoolcache/Java*"
fi
if [[ "${retain_toolcache_pypy}" != "true" ]]; then
export DirPurgeList+=" /opt/hostedtoolcache/PyPy"
fi
if [[ "${retain_toolcache_python}" != "true" ]]; then
export DirPurgeList+=" /opt/hostedtoolcache/Python"
fi
if [[ "${retain_toolcache_ruby}" != "true" ]]; then
export DirPurgeList+=" /opt/hostedtoolcache/Ruby"
fi
if [[ "${retain_toolcache_go}" != "true" ]]; then
export DirPurgeList+=" /opt/hostedtoolcache/go"
fi
if [[ "${retain_toolcache_node}" != "true" ]]; then
export DirPurgeList+=" /opt/hostedtoolcache/node"
fi
if [[ ${retain_compiler_all} == "true" ]]; then
for i in gcc gfortran llvm_clang cmake; do export retain_compiler_${i}="true"; done
fi
if [[ ${retain_compiler_gcc} != "true" ]]; then
case "$(lsb_release -rs)" in
"22.04") export AptPurgeList+=" g++-9 g++-10 g++-12 gcc-9 gcc-10 gcc-12" ;;
"20.04") export AptPurgeList+=" g++-10 g++-12 gcc-10 gcc-12" ;;
esac
fi
if [[ ${retain_compiler_gfortran} != "true" ]]; then
export AptPurgeList+=" gfortran-*"
fi
if [[ ${retain_compiler_llvm_clang} != "true" ]]; then
export AptPurgeList+=" clang-* libclang* llvm-* libllvm* lldb-* lld-* clang-format-* clang-tidy-*"
export DirPurgeList+=" /usr/lib/llvm-*"
fi
if [[ ${retain_compiler_cmake} != "true" ]]; then
export DirPurgeList+=" $(parallel -j4 echo /usr/local/bin/{} ::: ccmake cmake cmake-gui cpack ctest)"
export DirPurgeList+=" /usr/local/share/cmake-* /usr/local/*cmake* /usr/local/*/*cmake*"
fi
if [[ ${retain_powershell} != "true" ]]; then
export AptPurgeList+=" powershell"
export DirPurgeList+=" /opt/microsoft/powershell /usr/local/share/powershell"
fi
if [[ ${retain_rust} != "true" ]]; then
export DirPurgeList+=" /usr/share/rust /home/runner/.cargo /home/runner/.rustup /etc/skel/.rustup /etc/skel/.cargo /etc/.rustup /etc/.cargo"
fi
if [[ ${retain_haskell} != "true" ]]; then
ghcup nuke &>/dev/null || true
export DirPurgeList+=" /usr/local/bin/stack /home/runner/.ghcup /usr/local/.ghcup"
fi
if [[ ${retain_rlang} != "true" ]]; then
export AptPurgeList+=" r-base* r-cran* r-doc* r-recommended"
fi
if [[ ${retain_kotlin} != "true" ]]; then
export DirPurgeList+=" /usr/share/kotlinc /usr/bin/kotlin*"
fi
if [[ ${retain_julia} != "true" ]]; then
export DirPurgeList+=" /usr/local/julia* /usr/bin/julia"
fi
if [[ ${retain_swift} != "true" ]]; then
export DirPurgeList+=" /usr/share/swift /usr/local/bin/swift /usr/local/bin/swiftc"
fi
if [[ ${retain_snapd} != "true" ]]; then
{
for i in lxd core20; do sudo snap remove --purge ${i}; done
sudo snap remove --purge snapd
} &>/dev/null
sudo bash -c 'cat >/etc/apt/preferences.d/nosnap' <<EOX
Package: snapd
Pin: release a=*
Pin-Priority: -10
EOX
export AptPurgeList+=" snapd"
export DirPurgeList+=" /var/cache/snapd /home/runner/snap"
fi
if [[ ${retain_manpages} != "true" ]]; then
export AptPurgeList+=" man-db manpages"
fi
if [[ ${retain_libgtk} != "true" ]]; then
export AptPurgeList+=" libgtk-3-* ubuntu-mono *-icon-theme"
fi
# TODO: Add Additional apt Packages to be Removed
if [[ "$(lsb_release -rs)" == "20.04" ]]; then
export AptPurgeList+=" esl-erlang" DirPurgeList+=" /usr/local/bin/rebar3"
fi
export AptPurgeList+=" imagemagick imagemagick-6-common libgl1-mesa-dri firebird* hhvm "
export DirPurgeList+=" /usr/share/firebird* /opt/hhvm /usr/share/sbt /usr/bin/sbt /usr/local/share/phantomjs* /usr/local/bin/phantomjs /usr/local/bin/packer /usr/local/lib/lein /usr/local/bin/lein /usr/local/bin/pulumi /usr/local/bin/pulumi-* /usr/share/miniconda /usr/bin/conda /usr/local/lib/heroku"
echo "::group:: {[-]} Uninstalling and Purging apt Packages"
# Case #1. List has no missing packages / essential packages
# All Done in Step 1
# Case #2. List has missing packages
# Use _apt2unset to remove missing packages
# and try again from start
# Case #3. List has essential packages
# Use _esscheck_process to deselect essentials
# and try again from start
# ESSCheck variables
export ESStart='WARNING: The following essential packages will be removed.' ESEnd='0 upgraded, 0 newly installed'
# main uninstaller function _apt2purge_base
_apt2purge_base() {
sudo -EH apt-get remove --quiet --assume-no --auto-remove --purge --fix-broken ${AptPurgeList} 1>/tmp/apt2purge.info 2>/tmp/apt2purge.log
sed -i.bak 's/'$'\u001b''//g;s/\[1;31m//g;s/\[0m//g' /tmp/apt2purge.{info,log} 2>/dev/null
}
# function apt2unset
_apt2unset() {
echo -e "[i] Skipping Non-existing apt Packages: ${apt2unset}"
for i in ${apt2unset}; do
if grep -q '*' <<<"${i}"; then i=$(sed 's/\*/\\*/g' <<<"${i}"); fi
export AptPurgeList=" ${AptPurgeList} "
export AptPurgeList=$(sed 's/'" ${i} "'/ /g' <<<"${AptPurgeList}")
done
}
# function _esscheck_process
_esscheck_process() {
if ! grep -q "${ESEnd}" /tmp/apt2purge.log; then
export ESEnd=$(tail /tmp/apt2purge.log | grep -e "upgraded\|newly installed\|to remove")
fi
export EsnPackages=$(sed -e 's/'"${ESStart}"'/\n'"${ESStart}"'\n/' -e 's/'"${ESEnd}"'/\n'"${ESEnd}"'\n/' /tmp/apt2purge.log | sed -n '/'"${ESStart}"'/,/'"${ESEnd}"'/{//!p}' | sed -e '1d;2d;$d;s/due to //g;s/^\s\s//g;s/[()]//g' | tr ' ' '\n' | sort -u | paste -sd' ')
export AllPackages=" $(grep '*' /tmp/apt2purge.log | sed 's/\*//g;s/^\s\s//g' | tr ' ' '\n' | sort -u | paste -sd' ') "
export AllPackages=" ${AllPackages} "
for i in ${EsnPackages}; do export AllPackages=$(sed 's/'" ${i} "'/ /g' <<<"${AllPackages}"); done
}
export -f _apt2purge_base _apt2unset _esscheck_process
# The whole function serves as Case #3
_apt2purge_on_essfix() {
# The following function handles Case #1
_apt2purge_base
export apt2unset=$(grep "Unable to locate package" /tmp/apt2purge.log | awk '{print $NF}' | paste -sd' ')
# The following conditional block handles Case #2
if [[ ${apt2unset} != "" ]]; then
if grep -q "hhvm" <<<"${apt2unset}"; then export DirPurgeList=$(sed 's|\s/opt/hhvm||g' <<<"${DirPurgeList}"); fi
_apt2unset
if [[ ${AptPurgeList} != "" && ${AptPurgeList} != " " ]]; then
_apt2purge_base
fi
fi
}
echo -e "[i] List of apt Packages to be Removed: ${AptPurgeList}"
# >>> Case #1 + Case #2
_apt2purge_on_essfix
# >>> Case #3: Has Essential packages
if grep -q "${ESStart}" /tmp/apt2purge.log; then
_esscheck_process
export AptPurgeList=" ${AllPackages} "
_apt2purge_on_essfix
fi
# Redendent apt cleanup
sudo apt autoclean >/dev/null || true
sudo apt autoremove -qy 2>/dev/null || true
sudo rm -rf /var/cache/apt/archives/ 2>/dev/null || true
echo "::endgroup::" echo "::endgroup::"
echo "::group::Removing Lots of Cached Programs & Unneeded Folders" echo "::group:: {[-]} Purging Unnecessary Files and Directories"
printf "Removing Runner Tool Cache, Android SDK, NDK, Platform Tools, Gradle, Maven...\n" parallel 'echo -e "Purging {}" && sudo rm -rf -- {}' ::: ${DirPurgeList}
parallel --use-cpus-instead-of-cores sudo rm -rf -- {} 2>/dev/null ::: /opt/hostedtoolcache ::: /usr/local/lib/android ::: /usr/share/gradle* /usr/bin/gradle /usr/share/apache-maven* /usr/bin/mvn # Delete broken symlinks
printf "Removing Microsoft vcpkg, Miniconda, Leiningen, Pulumi...\n" sudo find /home/runner/.local/ /home/runner/ /usr/share/ /usr/bin/ /usr/local/bin/ /usr/local/share/ /usr/local/ /opt/ /snap/ -xtype l -delete 2>/dev/null
parallel --use-cpus-instead-of-cores sudo rm -rf -- {} 2>/dev/null ::: /usr/local/share/vcpkg /usr/local/bin/vcpkg ::: /usr/share/miniconda ::: /usr/bin/conda /usr/local/lib/lein /usr/local/bin/lein /usr/local/bin/pulumi*
printf "Removing Browser-based Webdrivers, PHP, Composer, Database Management Program Remains...\n"
parallel --use-cpus-instead-of-cores sudo rm -rf -- {} 2>/dev/null ::: /usr/share/java/selenium-server-standalone.jar /usr/local/share/phantomjs* /usr/local/bin/phantomjs /usr/local/share/chrome_driver /usr/bin/chromedriver /usr/local/share/gecko_driver /usr/bin/geckodriver ::: /etc/php /usr/bin/composer /usr/local/bin/phpunit ::: /var/lib/mysql /etc/mysql /usr/local/bin/sqlcmd /usr/local/bin/bcp /usr/local/bin/session-manager-plugin
printf "Removing Julia, Rust, Cargo, Rubygems, Rake, Swift, Haskell, Erlang...\n"
parallel --use-cpus-instead-of-cores sudo rm -rf -- {} 2>/dev/null ::: /usr/local/julia* /usr/bin/julia ::: /usr/share/rust /home/runner/.cargo /home/runner/.rustup /home/runner/.ghcup ::: /usr/local/bin/rake /usr/local/bin/rdoc /usr/local/bin/ri /usr/local/bin/racc /usr/local/bin/rougify ::: /usr/local/bin/bundle /usr/local/bin/bundler /var/lib/gems ::: /usr/share/swift /usr/local/bin/swift /usr/local/bin/swiftc /usr/bin/ghc /usr/local/.ghcup /usr/local/bin/stack /usr/local/bin/rebar3 /usr/share/sbt /usr/bin/sbt /usr/bin/go /usr/bin/gofmt
printf "Removing Various Cloud CLI Tools, Different Kubernetes & Container Management Programs...\n"
parallel --use-cpus-instead-of-cores sudo rm -rf -- {} 2>/dev/null ::: /usr/local/bin/aws /usr/local/bin/aws_completer /usr/local/aws-cli /usr/local/aws /usr/local/bin/aliyun /usr/share/az_* /opt/az /usr/bin/az /usr/local/bin/azcopy* /usr/bin/azcopy /usr/lib/azcopy /usr/local/bin/oc /usr/local/bin/oras ::: /usr/local/bin/packer /usr/local/bin/terraform /usr/local/bin/helm /usr/local/bin/kubectl /usr/local/bin/kind /usr/local/bin/kustomize /usr/local/bin/minikube /usr/libexec/catatonit/catatonit
printf "Removing Microsoft dotnet Application Remains, Java GraalVM, Manpages, Remains of Apt Package Caches...\n"
parallel --use-cpus-instead-of-cores sudo rm -rf -- {} 2>/dev/null ::: /usr/share/dotnet ::: /usr/local/graalvm ::: /usr/share/man ::: /var/lib/apt/lists/* /var/cache/apt/archives/*
echo "::endgroup::" echo "::endgroup::"
echo "::group::Clearing Unwanted Environment Variables" echo "::group:: {[-]} Clearing Journal Logs"
printf "This However is Not Retained after the Step is finished. So this part might be removed in the future.\n" sudo journalctl --rotate && sudo journalctl --vacuum-time=1s
{ sudo find /var/log -type f -regex ".*\.gz$" -delete
sudo sed -i -e '/^PATH=/d;/hostedtoolcache/d;/^AZURE/d;/^SWIFT/d;/^DOTNET/d;/DRIVER/d;/^CHROME/d;/HASKELL/d;/^JAVA/d;/^SELENIUM/d;/^GRAALVM/d;/^ANT/d;/^GRADLE/d;/^LEIN/d;/^CONDA/d;/^VCPKG/d;/^ANDROID/d;/^PIPX/d;/^HOMEBREW/d;' /etc/environment sudo find /var/log -type f -regex ".*\.[0-9]$" -delete
sudo sed -i '1i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' /etc/environment sudo find /var/log/ -type f -exec sudo cp /dev/null {} \;
sed -i '/HOME\/\.local\/bin/d' /home/runner/.bashrc
source /home/runner/.bashrc
} &>/dev/null
echo "::endgroup::" echo "::endgroup::"
echo "::group::Disk Space After Cleanup" echo "::group::<{[>]}> Free Disk Space After Cleanup <{[<]}>"
df -hlT / df --sync -BM --output=pcent,used,avail /
echo "::endgroup::" echo "::endgroup::"
printf "\nIf this action really helped you,\n Go to https://github.com/marketplace/actions/github-actions-cleaner\n And show your love by giving a star.\n\n"
exit