Ever tried deploying a GitHub Organization repo to Vercel and hit a paywall? Yeah, that can be frustrating. While Vercel is awesome for hosting Next.js apps and offers free hosting for personal repos, they'll ask you to upgrade to a paid plan if you want to deploy from an organization's repository.
But don't worry! I've got a workaround for you. We'll set up a GitHub Action that copies your org's repository content to your personal GitHub account. This way, you can still use Vercel's free hosting. Pretty neat, right?
What you'll need
- A GitHub account (your personal one)
- A repo inside a GitHub Organization (we'll call this the source)
- Another repo in your personal account (this is where we'll copy everything)
Heads up! While this solution works great for many cases, make sure you're careful with sensitive data if you're handling any.
Step 1: Create SSH Keys
First things first, we need to set up an SSH Deploy Key. This is how we'll securely push stuff from your org's repo to your personal one. Sure, you could use a Personal Access Token, but an SSH deploy key is safer - if something goes wrong, the damage is limited.
Here's what you need to run:
Just swap <desitination-repo-name>
with whatever you named your personal repo. After running this, you'll get two files:
github-<desitination-repo-name>.pub
(the public one)github-<desitination-repo-name>
(the private one)
Step 2: Add the Private Key to Your Source Repo
- Head over to your source repo on GitHub
- Click "Settings"
- Look for "Secrets" in the sidebar, then "Actions"
- Hit "New repository secret"
- Call it
SSH_DEPLOY_KEY
and paste your private key in there - Save it!
Step 3: Add the Public Key to Your Personal Repo
- Go to your personal repo
- Hit "Settings"
- Find "Deploy keys" in the sidebar
- Click "Add deploy key"
- Paste in your public key
- Make sure to check "Allow write access"
- Save it!
Step 4: Turn Off GitHub Actions in Your Personal Repo
This is important! We don't want our actions running twice:
- Go to your personal repo
- Click "Settings"
- Find "Actions" then "General"
- Pick "Disable actions"
- Save those changes!
Step 5: Set Up the GitHub Action
Now for the fun part! Create a new file in your source repo at .github/workflows/push-to-external-repo.yml
and drop this in:
Don't forget to replace <your-username>
with your actual GitHub username and <destination-repo-name>
with your personal repo's name!
Step 6: Test it Out!
Push something to your main
branch and watch the magic happen - your changes should show up in your personal repo automatically!
Step 7: Set Up on Vercel
Almost done! Here's how to get it live on Vercel:
- Go to Vercel's "New Project" page
- Pick your account under "Import Git Repository"
- Find your personal repo and click "Import"
- Vercel's pretty smart - it'll figure out most settings automatically
- Hit "Deploy" and you're good to go! 🚀