LaunchPad guides

How to Deploy a Private GitHub Repository Safely

Hostmargin · · 2 min read
How to Deploy a Private GitHub Repository Safely

Your website can be public while its code stays private. LaunchPad can deploy a private GitHub repository, or a private GitLab one, without you sharing a password or a personal access token. It uses a deploy key: a read-only key that works for one repository only.

Why a deploy key?

  • Read-only. It can clone the code but never push changes.
  • One repository. It can't see your other repositories.
  • Revocable. Remove it on GitHub or GitLab at any time, and access stops immediately.
  • No passwords shared. Your GitHub login and tokens stay with you.

The private half of the key is stored encrypted and only used during the clone.

Step 1: Create the project

  1. Sign in at launchpad.hostmargin.com and click New project.
  2. Choose GitHub or GitLab and paste the repository's HTTPS URL, for example https://github.com/your-name/client-site.
  3. Tick This is a private repository.
  4. Choose your framework preset and subdomain, and create the project.

Step 2: Copy the deploy key

Right after you create the project, LaunchPad shows its public deploy key. You can always find it again in Settings → Deploy key.

Step 3: Add it to your repository

On GitHub: open the repository, go to Settings → Deploy keys → Add deploy key, title it LaunchPad, paste the key and leave Allow write access off.

On GitLab: open the project, go to Settings → Repository → Deploy keys, add the key and leave write access off.

Step 4: Deploy

Click Deploy now on the project page. LaunchPad clones over SSH with the key, builds your site and publishes it. Add the webhook from Settings to your repository, and every push deploys automatically, exactly as with a public repository.

Troubleshooting

"Permission denied (publickey)"

The key isn't on that repository yet, or it was added to a different one. Check the repository's Deploy keys page and add it again if needed.

Need a new key?

Use Regenerate key in Settings, then replace the old key in your repository. The old key stops working.

Renamed or moved the repository?

Update the repository URL in the project's Settings, and check that the deploy key is still listed on the repository's Deploy keys page.

Working in a team?

Invite teammates to the project as editors or viewers on the Pro and Business plans. They can deploy and read logs without ever needing access to the deploy key.

Next steps

Ship your next site today

Three projects free, forever. Sign in with your Hostmargin account — no credit card required.