Deploy to Hostinger VPS using GitHub Actions

Updated 3 weeks ago

With the Deploy to Hostinger VPS GitHub Action, you can automatically deploy your Docker applications to a Hostinger VPS directly from your repository. Every push to your branch can trigger a deployment, making CI/CD efficient and straightforward.

Prerequisites

  • A Hostinger VPS with a Docker template installed.
  • A docker-compose.yml file in your repository.
  • A Hostinger API key (generated in hPanel).
  • Your VPS Virtual Machine ID (found in the VPS overview URL or default hostname).
  • (Optional) GitHub Personal Access Token for private repositories.

Setting up GitHub Secrets and Variables

  1. Generate Hostinger API Key in hPanel → API settings.

  2. Find VM ID: e.g. srv123456.hstgr.cloud → VM ID is 123456.

  3. In your GitHub repository, go to Settings → Secrets and variables → Actions.

    • Add secret: HOSTINGER_API_KEY

    • (Optional) Add secret: PERSONAL_ACCESS_TOKEN

    • Add variable: HOSTINGER_VM_ID

Example workflow (public repository)

name: Deploy to Hostinger

on:
push:
branches: [ main ]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Deploy to Hostinger
uses: hostinger/deploy-action@v1
with:
api-key: ${{ secrets.HOSTINGER_API_KEY }}
virtual-machine: ${{ vars.HOSTINGER_VM_ID }}

Example workflow (private repo with environment variables)

name: Deploy to Hostinger

on:
push:
branches: [ main, production ]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Deploy to Hostinger
uses: hostinger/deploy-action@v1
with:
api-key: ${{ secrets.HOSTINGER_API_KEY }}
virtual-machine: ${{ vars.HOSTINGER_VM_ID }}
project-name: my-awesome-app
personal-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
docker-compose-path: docker/docker-compose.yml
environment-variables: |
NODE_ENV=production
API_URL=https://api.example.com
DATABASE_URL=${{ secrets.DATABASE_URL }}

Once configured, every push or tag can automatically redeploy your application on your Hostinger VPS.