← Back to blog

How to Deploy Docker Apps to a VPS with GitHub Actions

July 15, 2025 · Guides

As a developer, automating your deployment process can save you time and reduce the risk of human error. In this post, we'll explore how to use GitHub Actions to deploy Docker images to a VPS (Virtual Private Server) using Serversinc. We'll cover the setup process, including creating a GitHub Action that builds and pushes a Docker image, and then triggers a deployment on Serversinc using a webhook.

Prerequisites

Before we begin, make sure you have the following:

  • A Serversinc account with a connected VPS and application set up
  • A GitHub repository with your Docker image configuration
  • Docker installed on your local machine and a Docker Hub account

You don't need to deploy the application, just create it on your server.

Step 1: Configure Your Serversinc Application

To start, log in to your Serversinc dashboard and navigate to the application you want to deploy to. Click on the Settings tab and scroll down to the Webhooks section. You'll see a Deploy Hook value and a Deploy Secret value. Take note of these values, as you'll need them later.

Step 2: Create a GitHub Action

In your GitHub repository, create a new file in the .github/workflows directory called deploy.yml. This file will define the GitHub Action that will build and push your Docker image, and then trigger a deployment on Serversinc.

name: Deploy to VPS

on:
  push:
    branches:
      - main

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

      - name: Login to Docker Hub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Build and push Docker image
        run: |
          docker build -t my-image .
          docker tag my-image ${{ secrets.DOCKER_USERNAME }}/my-image:latest
          docker push ${{ secrets.DOCKER_USERNAME }}/my-image:latest

      - name: Trigger deployment on Serversinc
        run: |
          curl -X POST \
          https://dash.serversinc.io/events/${{ secrets.SERVERSINC_HOOK }} \
          -H 'X-Deploy-Secret: ${{ secrets.SERVERSINC_SECRET }}' \
          -H 'Content-Type: application/json' \
          -d '{"tag": "latest"}'

In this example, we're using the docker/login-action to log in to Docker Hub, and then building and pushing our Docker image using the docker build and docker push commands. Finally, we're using curl to trigger a deployment on Serversinc using the webhook endpoint.

Step 3: Store Your Secrets

In your GitHub repository, go to Settings > Actions > Secrets. Add the following secrets:

  • DOCKER_USERNAME: your Docker Hub username
  • DOCKER_PASSWORD: your Docker Hub password
  • SERVERSINC_HOOK: the Hook value from your Serversinc application settings
  • SERVERSINC_SECRET: the Secret value from your Serversinc application settings

Step 4: Test Your Deployment

Once you've set up your GitHub Action and stored your secrets, test your deployment by pushing a new commit to your repository. The GitHub Action should trigger, build and push your Docker image, and then deploy it to your VPS on Serversinc.

Why Use Serversinc for CI/CD?

Serversinc gives you the power of traditional self-hosting — low cost, full control, and no vendor lock-in — without the friction. You still get an API, a dashboard, instant deploy hooks, real-time logs, and smart container orchestration.

By combining GitHub Actions and Serversinc, you can:

  • Keep your infra portable and developer-friendly
  • Avoid overcomplicated CI/CD pipelines
  • Move fast while keeping control

Conclusion

This setup gives you a clean, end-to-end deployment pipeline in just a few steps. You write code, push to GitHub, and Serversinc takes care of the rest.

If you're tired of bloated DevOps tools or overpriced PaaS platforms, sign up for an account today at https://serversinc.io and start shipping faster.