While building my website 🌐, I ran into an architecture constraint 🧠.
My entire repository needed to stay private 🔒 because it contains drafts and internal structure. However, one folder (/website) powers the basic version of my blog and had to be public 🌍.
I didn’t want:
Duplicate repositories 📂
Manual copying ❌
Risk of exposing private files 🚫
Inconsistent content between repos 🔁
⚙️ The Solution
I implemented a GitHub Actions workflow 🤖 inside the private repository that:
Triggers only on website/** changes 📁
Uses a Personal Access Token (PAT) stored as a secret 🔑
Clones the public repository 🌐
Syncs using rsync --delete 🪞
Commits and pushes automatically 🚀
The --delete flag ensures removed files are also mirrored, keeping both repositories perfectly in sync 🔄.
🏗️ Final Setup
Private repo → Full development workspace 🧑💻
Public repo → Clean blog content layer 📦
Publishing → Fully automated pipeline ⚡
This approach keeps a single source of truth 📌 while maintaining proper separation of concerns 🧩.
If you're facing similar repo separation challenges, this pattern works cleanly and reliably.
Full step-by-step guide 🔗
https://vineelvanjari.com/blog/sync-private-repo-subfolder-to-public-repo-using-github-actions
Top comments (0)