If you're hosting your project on a private GitHub repository and want to deploy it to a VPS (Virtual Private Server), you’re likely wondering:

  • How do I pull private code securely to my server?
  • How do I automate deployment when I push to main?

You’re in the right place.


πŸ’‘ Why This Matters

Manually logging into a server every time you push an update is:

  • ❌ Time-consuming
  • ❌ Error-prone
  • ❌ Not scalable

Instead, you can automate the deployment process by securely connecting GitHub to your VPS and using GitHub Actions to trigger updates. This guide is divided into two simple, beginner-friendly parts:


πŸ› οΈ Part 1 – Pull Private GitHub Repo on VPS Using SSH Deploy Keys

In this part, you'll learn:

  • How to set up a dedicated deploy user on your server
  • How to generate SSH keys
  • How to securely connect your server to your private GitHub repo using Deploy Keys

πŸ‘‰ Read Part 1:
How to Pull a Private GitHub Repo on VPS Using SSH Deploy Keys


πŸ”„ Part 2 – Auto Deploy to VPS Using GitHub Actions

Once your VPS can securely pull code, this part shows how to:

  • Store your private SSH key in GitHub Secrets
  • Configure a GitHub Actions workflow
  • Automatically pull the latest code and restart services (like nginx) after every push

πŸ‘‰ Read Part 2:
How to Auto-Deploy Code to VPS Using GitHub Actions and SSH


🎯 What You'll Achieve

By following these two guides, you’ll have:

βœ… A secure, passwordless connection between GitHub and your VPS
βœ… Automated deployment every time you push to your repository
βœ… A scalable and production-ready CI/CD foundation


πŸ“Œ Final Thoughts

Setting this up once can save you hours of manual work in the future. It’s ideal for developers, solo founders, and teams managing custom apps or static websites on VPS or cloud platforms like DigitalOcean, Linode, or AWS EC2.

Let’s automate responsibly β€” with security first!