Skip to main content
DeployHub tracks Git branches and commits to enable automatic redeployments when your code changes. Learn how to configure branch selection and monitor commit history.

Branch Configuration

Specify which branch to deploy from using the branchname field:
Common branch names:
  • main (default)
  • master
  • develop
  • staging
  • production

Validation

The branchname field is required for all deployments.
From the validation schema:

Database Storage

Branch settings are stored in the project model:

Commit Tracking

DeployHub automatically tracks the commit SHA of each deployment for change detection.

Build Model

Commits are tracked in the Build model:

Fetching Commit SHA

During deployment, DeployHub fetches the latest commit SHA from GitHub:

Storing Commit SHA

The commit SHA is stored with each build:

Deployment Request with Branch

1

Specify branch in deployment request

2

DeployHub fetches latest commit

The commit SHA is automatically fetched from the specified branch.
3

Build is created with commit tracking

Git Clone with Branch

DeployHub clones the specified branch during build:

Automatic Redeployment

DeployHub intelligently redeployes based on commit changes.

Change Detection

The redeploy worker compares commit SHAs:

Rebuild Triggers

A rebuild is triggered when:
  1. Previous build failed: buildData.status === "failed"
  2. New commit detected: buildData.commitSha !== commitSha

Redeployment Without Rebuild

If the commit hasn’t changed and the build succeeded, DeployHub redeploys the existing Docker image:

GitHub Webhook Integration

After successful deployment, DeployHub sets up a webhook for automatic redeployments:
Webhooks are only created if the user has provided a GitHub access token.

Webhook Events

The webhook triggers on:
  • Push events: Commits pushed to the configured branch
  • Automatic redeployment: DeployHub detects the new commit and redeploys

Updating Branch Settings

Change the branch via the settings API:
Changing the branch requires a redeployment to build from the new branch.

Manual Redeployment

Trigger a manual redeployment:
This will:
  1. Check for new commits on the configured branch
  2. Rebuild if new commits are detected
  3. Redeploy the application

Branch Strategy Examples

Production Deployment

Staging Deployment

Development Deployment

Feature Branch Deployment

Multi-Environment Setup

Deploy multiple environments from different branches:

Project Settings Response

When fetching project settings, branch info is included:

Troubleshooting

Branch Not Found

Ensure the branch exists in your repository before deploying.

Commit SHA Not Fetched

If commit tracking fails:
  • Check that the repository is public or GitHub token is provided
  • Verify branch name is correct
  • Ensure GitHub API is accessible

Webhook Not Triggering

  • Verify webhook is created in GitHub repository settings
  • Check webhook secret matches
  • Ensure webhook URL is accessible
  • Review webhook delivery logs in GitHub

Rebuild Not Triggered

If changes aren’t detected:
  • Verify commits are pushed to the correct branch
  • Check that the webhook is firing
  • Manually trigger redeployment to force a check

Best Practices

Protected Branches

Use protected branches for production deployments

Branch Naming

Use consistent branch naming conventions across projects

Commit Messages

Write clear commit messages for deployment tracking

Testing

Test on staging branches before deploying to production

Next Steps

Static Sites

Deploy React, Vue, Angular apps

Node.js Apps

Deploy Express, Nest.js backends

Monorepo Support

Deploy from specific folders