
Sync a Private Repo Subfolder to a Public Repo Using GitHub Actions 🔄🚀
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 o
Continue reading on Dev.to Webdev
Opens in a new tab


