How do I resolve "no space left on device" error during GitHub builds?

Last updated: April 1, 2025

Context

When building and deploying preview environments through GitHub Actions, you may encounter an error message stating "no space left on device". This typically occurs during the build process when the GitHub runner machine doesn't have sufficient disk space to complete the operation.

Answer

There are two recommended solutions to resolve the "no space left on device" error:

  1. Increase GitHub Runner Machine Size
    If you have a GitHub plan that allows for larger runners, upgrade your runner to a machine with more disk space.

  2. Use the Free Disk Space Action
    Add the "Free Disk Space Ubuntu" GitHub Action to your workflow. This action helps clear unnecessary files from the runner to free up disk space.

    You can find this action at: GitHub Marketplace - Free Disk Space Ubuntu

The second option using the Free Disk Space Action is particularly helpful if you're using the default GitHub-hosted runners and don't have the option to increase machine size.