Branch Configuration
Specify which branch to deploy from using thebranchname field:
Common branch names:
main(default)masterdevelopstagingproduction
Validation
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:- Previous build failed:
buildData.status === "failed" - 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:Manual Redeployment
Trigger a manual redeployment:- Check for new commits on the configured branch
- Rebuild if new commits are detected
- 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
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