Skip to content

Commit

Permalink
ci(github): Add a composite action to free disk space
Browse files Browse the repository at this point in the history
Add a composite action [1] that removes unneeded Docker images and
preinstalled tools to increase the available disk space. This will be
used by jobs that build the ORT Docker image, as otherwise the 14 GB
free disk space that GitHub guarantees [2] are not sufficient.

After the action is executed there are approximately 40 GB disk space
available.

This action could later be replaced by an existing alternative like [3]
or [4], but for now the custom action will be used in the following
changes as it is proven to work for the Docker build jobs.

[1]: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
[2]: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
[3]: https://github.com/easimon/maximize-build-space
[4]: https://github.com/AdityaGarg8/remove-unwanted-software

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Apr 16, 2024
1 parent fe8829c commit 3fb7c9b
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/actions/free-disk-space/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright (C) 2024 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# License-Filename: LICENSE

name: "Free Disk Space"
description: "Remove unneeded preinstalled Docker images and software to free disk space."
author: "The ORT Project Authors"

runs:
using: "composite"

steps:
- name: Print Disk Space
shell: bash
run: df -h
- name: List Docker Images
if: ${{ false }} # Can be enabled if the 'Remove Unneeded Docker Images' step below needs to be updated.
shell: bash
run: docker images
- name: Remove Unneeded Docker Images
shell: bash
run: |
docker image rm \
node:16 \
node:16-alpine \
node:18 \
node:18-alpine \
node:20 \
node:20-alpine \
debian:10 \
debian:11 \
ubuntu:20.04 \
ubuntu:22.04
- name: Print Disk Space
shell: bash
run: df -h
- name: Get Size of Installed Tools
if: ${{ false }} # Can be enabled if the 'Remove Unneeded Tools' step below needs to be updated.
shell: bash
run: |
sudo du -hsc /usr/lib/*
sudo du -hsc /usr/local/*
sudo du -hsc /usr/local/lib/*
sudo du -hsc /usr/local/share/*
sudo du -hsc /usr/share/*
- name: Remove Unneeded Tools
shell: bash
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/share/az_11.3.1
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/share/kotlinc
sudo rm -rf /usr/share/mecab
sudo rm -rf /usr/share/miniconda
sudo rm -rf /usr/share/ri
sudo rm -rf /usr/share/sbt
sudo rm -rf /usr/share/swift
- name: Print Disk Space
shell: bash
run: df -h

0 comments on commit 3fb7c9b

Please sign in to comment.