Skip to content

Latest commit

 

History

History
87 lines (60 loc) · 1.91 KB

File metadata and controls

87 lines (60 loc) · 1.91 KB

Ultralytics logo

🧹 Disk Space Cleanup Action

Cleans up disk space on Ubuntu GitHub Actions runners by removing unnecessary tool caches, Docker images, and swap space.

🚀 Usage

Basic Usage

Add as early step in jobs requiring disk space:

Important

Run cleanup before pulling or building Docker images because it removes all images unused by containers.

steps:
  - uses: ultralytics/actions/cleanup-disk@main

  - name: Run disk-intensive task
    run: |
      docker build -t myimage .
      pytest --large-files

Complete Workflow Example

name: CI
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: ultralytics/actions/cleanup-disk@main

      - name: Build and test
        run: |
          pip install -e .
          pytest

With Other Actions

steps:
  - uses: actions/checkout@v4

  - uses: ultralytics/actions/cleanup-disk@main

  - uses: docker/setup-buildx-action@v3

  - name: Build Docker image
    run: docker build -t myapp .

🗑️ What Gets Cleaned

  • /opt/hostedtoolcache - Tool cache (~15GB)
  • Unused Docker images
  • /swapfile or /mnt/swapfile - Swap space (~4GB)

💡 When to Use

Use this action when your workflow:

  • Builds large Docker images
  • Processes large datasets or files
  • Runs out of disk space on GitHub-hosted runners
  • Requires more than the default ~14GB available space

📊 Before/After

The action displays disk space before and after cleanup:

Free space before deletion:
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        84G   60G   24G  72% /

Free space after deletion:
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        84G   41G   43G  49% /