Monorepos in Vercel how to deploy many websites from one codebase?

Damian Sowa
2 min readJun 7, 2023

I have one big (mono) repository that I am using to build many mobile apps (https://damiansowa.medium.com/how-to-release-many-mobile-apps-from-one-repository-in-capacitor-a5f0065f4ebe) about the driving licence learning (ex. https://www.korea.drivexam.com/en). After finding a solution for mobile development I’ve got the same problem with deploying web apps.

How to deploy many websites with Vercel from one repository?

Actually, in the beginning, I thought maybe I could set up different ENV variables for other domains, unfortunately, that option doesn’t exist. After checking Vercel documentation I’ve found that they recommend creating many Vercel projects and linking them to one repository. Actually, this solution works pretty well until …

I’ve found that for a free account in Vercel, you can link a maximum of 3 projects to one repository. I kinda liked the way how my websites were deployed already and I just wanted to add a 4th website at that moment. After some thinking, I have decided that a kinda simple solution will just copy the repository and create a mechanism for auto-updating this newly created repository based on the main one.

I’ve found ready Githbub action for that — repo-sync/github-sync@v2 (A GitHub Action for syncing the current repository using force push). After playing with it for a few minutes I managed to get what I wanted. Below I present my GitHub Workflow file:

# File: .github/workflows/sync.yml

on:
schedule:
- cron: "0 0 */1 * *"
workflow_dispatch:

jobs:
repo-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: repo-sync
uses: repo-sync/github-sync@v2
with:
source_repo: "https://${{ secrets.PAT }}@github.com/[USER]/[PROJECT].git"
source_branch: "main"
destination_branch: "main"
github_token: ${{ secrets.PAT }}

The only thing that is worth noticing is that, that you need to put this workflow in the destination repository on a different branch than you want to store code, so it prevents overwriting.

/
├── ex. "master" branch/
├── connected to Vercel
├── contains synchronised code from main branch
├── ex. "main" branch/
├── set up as main branch in Github
├── contains workflow file

After all of this setup, your dependent repository should update itself once a day. You can also run it manually. After doing all of this I can have as many free web deployments from one repository in Vercel.

--

--