Skip to main content
DeployHub supports deploying specific folders from monorepos or large repositories, allowing you to deploy only the code you need without cloning the entire repository.

Overview

Folder-based deployments use Git sparse checkout to clone only specific directories, making deployments faster and more efficient for monorepo structures.

Configuration

Enable folder deployment by setting isFolder: true and specifying the folder name:

Validation Rules

Folder deployment requirements:
  • isFolder must be a boolean value
  • When isFolder is true, folderName is required
  • folderName must be a non-empty string
From the validation schema:

Database Schema

Folder settings are stored in the project model:

How It Works

1

Sparse Checkout Initialization

DeployHub clones the repository with blob filtering and enables sparse checkout:
This downloads only the repository structure, not file contents.
2

Configure Sparse Checkout

Sets which folder to checkout:
Only files in the specified folder are downloaded.
3

Move Folder Contents

The folder contents are moved to the build root:
4

Build and Deploy

The folder contents are built and deployed as if they were the repository root.

Complete Build Worker Implementation

From buildworker.js:

Deployment Examples

Static Site in Monorepo

Node.js API in Monorepo

Nested Folder Structure

Monorepo Structures Supported

Nx Workspace

Turborepo

Lerna

Yarn Workspaces

Updating Folder Settings

Update folder configuration via the settings API:
Changing folder settings requires a redeployment to take effect.

Benefits

Faster Cloning

Sparse checkout only downloads the files you need:
  • Full clone: Downloads entire repository history and all files
  • Sparse checkout: Downloads only specified folder with --filter=blob:none

Reduced Build Time

Smaller directory = faster builds:

Lower Resource Usage

Less disk space and memory required for builds.

Redeployment with Folders

The redeploy worker also supports folder deployments:

Troubleshooting

Folder Not Found

Ensure the folder path is correct and exists in your repository.
Check your repository structure:

Build Fails After Folder Deploy

  • Verify package.json exists in the folder
  • Check that all dependencies are properly referenced
  • Ensure relative imports work from the folder root

Sparse Checkout Not Working

  • Verify Git version supports sparse checkout (Git 2.25+)
  • Check that --filter=blob:none is supported
  • Ensure folder name doesn’t have trailing slashes

Dependencies in Parent Directory

If your folder needs files from parent directories:

Best Practices

Self-Contained Folders

Ensure each deployable folder has its own package.json and dependencies

Relative Imports

Use path aliases for shared code instead of ../../ imports

Build Scripts

Keep build commands in the folder’s package.json

Environment Variables

Use folder-specific env vars to avoid conflicts

Next Steps

Branch Management

Configure branch selection and commit tracking

Static Sites

Deploy React, Vue, Angular apps

Node.js Apps

Deploy Express, Nest.js backends