Using Github Codespaces prebuilds in [#github-codespaces]

A Codespace prebuild is a template that GitHub uses to create new Codespaces faster. It leverages GitHub Actions and GitHub Codespaces to build a devcontainer for the latest changes to a branch even before contributors need to run that branch in a Codespace.

Configure Codespace prebuilds

Please see configuring prebuilds for setup instructions.

Pros

  • Faster Codespace creation. Based on LinkORB testing, new Codespace creation time was reduced by approximately 50% with a prebuild enabled.
  • Child branches inherit prebuilds from parent branches.
  • Ease of implementation.

Cons

  • Each prebuild consumes storage space and minutes against GitHub Actions quotas. This may increase billable charges.

Best practices

  • Minimize prebuild workflow runs by setting prebuild triggers to On configuration change when configuring a prebuild. This ensures the prebuild will only run when contributors push changes that affect the .devcontainer/devcontainer.json file and its associated (Dockerfile or docker-compose.yml) files.

  • Skip the prebuild action workflow for push and merge operations that affect the devcontainer configuration files but do not require a prebuild. Please see skipping workflow runs for instructions on how to accomplish this from your commit and pull request messages.

  • If working in a forked repository individually, shorten prebuild creation time and reduce storage consumption by modifying Region availability to upload the prebuild template to your local region only. Based on LinkORB testing, template upload to a single region can take approximately 30-40 seconds, while default prebuild settings uploading to all regions spans approximately 3 minutes and 30 seconds. Read more about Codespace regional settings.

Reducing region availability for prebuilds may not be desirable for repositories where global team members are creating branches directly within the repository.

Other relevant notes

  • Only contributors with admin access can configure Codespace prebuilds for a repository.
  • Prebuild configurations do not cascade to forked repositories.
About GitHub Codespaces