DEV Community

vineel vanjari
vineel vanjari

Posted on

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 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)