Multiple Sites in One Git Repo: How to Reduce Vercel/EdgeOne Duplicate Builds via Commit Prefix Branch Routing
If you maintain multiple websites within a single Git repository (for example, managing a primary site and an English version in one monorepo, or running international multi-language blogs) and deploy them to modern hosting platforms like Vercel, Tencent Cloud EdgeOne Pages, or Cloudflare Pages, you have likely encountered this frustrating issue:
Every single git push to GitHub triggers a full build across all connected sites!
- You update an article on Site A and push to GitHub, but Site B unnecessarily runs a full build as well.
- You fix a single typo on Site B, and Site A gets re-packaged and re-deployed.
- If you frequently push commits to GitHub for remote backups while drafting, monthly build minutes and concurrent build slots are quickly burned through, easily hitting platform rate limits.
To solve this, here is a lightweight, battle-tested solution that requires no proprietary platform features: Commit Prefix Routing + Isolated Release Branches.
Solution Architecture & Design Thinking
Many developers first think of platform-native “path diffing” (such as Vercel’s Ignored Build Step). However, that approach has two notable limitations:
- Inconsistent Platform Capabilities: Many emerging or regional hosting platforms have limited or buggy support for path-based build filters.
- Cannot Prevent Unfinished Drafts from Going Live: Even if you modify files in a specific directory, you might just want to push an incomplete draft to GitHub for safe backup without triggering an immediate production release.
A much more reliable approach is putting the release trigger directly into your own hands:
- Branch Separation of Concerns:
masterbranch: The main trunk where daily writing, code backups, and commit history reside.cd-zhbranch: Dedicated release branch for the primary (e.g., Chinese) site.cd-enbranch: Dedicated release branch for the secondary (e.g., English) site.
- Bind Dedicated Branches on Hosting Platforms:
- Platform Project A (Primary site): Set deployment branch from
mastertocd-zh. - Platform Project B (English site): Set deployment branch from
mastertocd-en.
- Platform Project A (Primary site): Set deployment branch from
- Use Commit Message Prefixes as Deployment Commands:
- Commits prefixed with
cd-zh(e.g.,cd-zh: publish new guide) → Pushes only tocd-zh, triggering only the primary site build. - Commits prefixed with
cd-en(e.g.,cd-en: add new post) → Pushes only tocd-en, triggering only the English site build. - Commits prefixed with
cd(e.g.,cd: full site upgradeor simplycd) → Updates both branches simultaneously, triggering both builds. - Regular commits (e.g.,
save draft,fix formatting) → Does not update any CD branch. Zero builds triggered, zero quota consumed!
- Commits prefixed with
GitHub Actions Workflow Implementation
Create a new file at .github/workflows/deploy-router.yml in your repository:
1 | |
Pro Tip (Eliminating Git Merge Conflicts):
The commandgit push origin master:cd-en --forceuses a forced fast-forward pointer update. The deployment branch acts purely as an ephemeral trigger signal. No matter how yourmastercommit history evolves, your deployment branches will never suffer from git merge conflicts.
Hosting Platform Configuration
Once the GitHub Action is in place, update your hosting platform settings (EdgeOne, Vercel, Cloudflare Pages, etc.):
- In the Site A Project: Navigate to Git Settings / Build Settings, and change the production branch from
mastertocd-zh. - In the Site B Project: Change the production branch from
mastertocd-en.
Everyday Workflow & Benefits
With this setup, deployment timing is completely under your control:
- Free-flow drafting: Push to GitHub whenever you want (
git commit -m "wip draft"&&git push). GitHub acts purely as a secure remote backup, completely silent to your production environments. - Deploying a single site: When an article is ready to go live:GitHub Actions responds in seconds, updates
1
2git commit -m "cd-zh: publish new practical tool tutorial"
git pushcd-zh, and only the target site triggers a build. - Full deployment: When updating global configs, themes, or simultaneous multi-language posts:Both platforms trigger builds simultaneously.
1
2git commit -m "cd: global configuration update"
git push
By adopting intent-driven commit routing, you drastically cut down on unnecessary builds and avoid accidentally deploying unfinished drafts.
Key Outcomes After This Transformation
- Safe Drafts & WIP Backups: As long as your commit message doesn’t start with
cd, zero builds are triggered. - Isolated Site Updates: Updating the English site only builds the English site, completely avoiding unwanted dual rebuilds.
- Effortless Dual Deployment: Whenever you want to update both Chinese and English sites simultaneously, simply start your commit message with
cd. - Fewer Build Triggers: Drastically reduces build frequency and prevents hitting quota or concurrency limits on Vercel, Tencent EdgeOne, and other platforms.
- A Greener Web: Makes a great contribution to saving planet-wide compute energy!
- Universal Compatibility: Works across all platforms and hosts; requires zero reliance on proprietary features like Vercel’s Ignored Build Step.
- Saves Precious Build Quotas: Preserves pipeline minutes and keeps deployments fast and predictable.