Back to Blog

Stop Deploying Manually — Claude Code Sets Up GitHub Actions Auto-Deploy to Hostinger

By Ayyaz Zafar
Stop Deploying Manually — Claude Code GitHub Actions auto-deploy to Hostinger tutorial thumbnail

I just pushed one commit to GitHub. 42 seconds later, my live API on Hostinger updated automatically. No SSH. No manual git pull. No PM2 restart.

Claude Code wrote the entire deploy pipeline for me — and I'm going to show you the exact prompt.

The Problem

Most developers deploy to a VPS the same painful way every time:

  1. SSH in
  2. Pull the code
  3. Install dependencies
  4. Restart the service
  5. Check the logs
  6. Hope nothing broke

Slow, error-prone, repeated every single push. The reason most people don't fix it is because GitHub Actions YAML is intimidating. So today I'll let Claude Code write it for me.

What We're Building

The full pipeline:

git push  →  GitHub Actions runner  →  SSH into Hostinger VPS
                                       →  git pull + npm install + pm2 restart
                                       →  live API updated

Whole thing under a minute end-to-end. Once it's set up, you never touch it again.

Prerequisites (4 things)

  1. A Hostinger VPS with Node + PM2 installed — covered in my 5-Minute Hostinger VPS Setup video.
  2. An app already deployed there.
  3. An SSH key pair specifically for GitHub Actions — not your personal SSH key.
  4. The PM2 process name of your app (run pm2 list on the VPS).

Generate the deploy key (3 commands)

ssh-keygen -t ed25519 -f ~/.ssh/hostinger_deploy_key_taskapi -C "github-actions-deploy-taskapi" -N ""
ssh-copy-id -i ~/.ssh/hostinger_deploy_key_taskapi.pub root@YOUR_VPS_IP
ssh -i ~/.ssh/hostinger_deploy_key_taskapi root@YOUR_VPS_IP "whoami"
  1. First command makes a brand-new key pair dedicated to this project.
  2. Second installs the public key on your VPS — you'll be asked for your VPS password once.
  3. Third confirms the key works without a password. If it prints root, you're ready.

The Claude Code Prompt That Does 90% of the Work

Open Claude Code in your project folder. One prompt:

Set up GitHub Actions to auto-deploy this repo to my Hostinger VPS at YOUR_VPS_IP
whenever I push to the main branch. Use SSH with a deploy key. On the VPS, the
app lives at /root/apps/task-tracker-api and is managed by PM2 with the process
name task-tracker. The workflow should: pull the latest code, run npm install
--production, and pm2 restart task-tracker. Tell me which GitHub Secrets I need
to add and exactly what values they should hold.

Claude Code creates .github/workflows/deploy.yml using the most reliable SSH action (appleboy/ssh-action) and tells you exactly what 3 secrets to add — no YAML guesswork, no Stack Overflow copy-paste.

The generated workflow

name: Deploy to Hostinger
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Deploy to VPS via SSH
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: ${{ secrets.VPS_HOST }}
          username: ${{ secrets.VPS_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          script: |
            cd /root/apps/task-tracker-api
            git pull origin main
            npm install --production
            pm2 restart task-tracker
            pm2 save

Add the 3 GitHub Secrets

In your GitHub repo: Settings → Secrets and variables → Actions → New repository secret. Add three:

NameValue
VPS_HOSTYour Hostinger VPS IP
VPS_USERroot
SSH_PRIVATE_KEYFull contents of the private key (including BEGIN/END lines)

Copy the private key to clipboard in one command:

cat ~/.ssh/hostinger_deploy_key_taskapi | pbcopy

Paste it as the value of SSH_PRIVATE_KEY. Save.

The Live Test (The Money Shot)

Make a tiny code change — edit the welcome message in the API — commit, push:

git add .
git commit -m "Update welcome message"
git push origin main

GitHub Actions catches the push immediately. Workflow starts. Spins up an Ubuntu runner. Checks out the code. SSHes into the VPS. Runs git pull, npm install, pm2 restart. Green.

Refresh the live API URL — new welcome message is live.

42 seconds, end to end. Never touched the server. From now on, every push to main deploys automatically.

Verify on the VPS (Builds Trust)

ssh -i ~/.ssh/hostinger_deploy_key_taskapi root@YOUR_VPS_IP
pm2 logs task-tracker --lines 20

PM2 logs show the restart happened seconds ago, and the new code is running. This is exactly what GitHub Actions did, except you didn't have to type any of it.

What to Extend Next

  • Add SSL with Certbot so the API runs over HTTPS
  • Point a real custom domain at the VPS
  • Set up separate staging and production environments
  • Fire a Slack notification when a deploy completes

Common Issues

IssueFast fix
Permission denied (publickey)The SSH_PRIVATE_KEY secret is missing the BEGIN/END lines. Re-paste the FULL key.
pm2 restart failsThe PM2 process name doesn't match. SSH in, run pm2 list, copy the exact name.
git pull fails inside ActionsVPS repo has uncommitted local changes. SSH in, fix the repo state once, push again.
Workflow doesn't trigger on pushThe branch name in the YAML (main) doesn't match your repo's default branch.

Resources

Related videos on AyyazTech

Final Word

GitHub Actions, Hostinger, and Claude Code — three tools, one prompt, fully automated deploys forever. The Hostinger affiliate link and the full deploy YAML are above.

Subscribe to AyyazTech on YouTube — I cover every AI coding tool worth your time so you don't waste yours.

Share this article