TECHNICAL ARTICLE

4/13/2026

Seamless CI/CD Pipeline: Deploying to CapRover

Prepare CapRover

First, you need to enable your CapRover application to accept external deployment triggers. Log in to your CapRover dashboard and go to your App.

  • Navigate to the Deployment tab.
  • Scroll down to Method 6: Deployment via App Token and click on "Enable App Token."
  • Copy and save the App Token and your CapRover URL (your dashboard address).

Configure GitHub Secrets

Security is paramount. Go to your GitHub repository and follow the path Settings > Secrets and variables > Actions to define the following Repository Secrets:

  • CAPROVER_SERVER: Your CapRover dashboard URL (e.g., https://captain.your-domain.com).
  • CAPROVER_APP_TOKEN: The app-specific token you generated in CapRover.
  • DOCKERHUB_USERNAME: Your Docker Hub username.
  • DOCKERHUB_TOKEN: An Access Token generated from your Docker Hub account (Account Settings > Security).

Create the GitHub Actions Workflow

This is the brain of your pipeline. Create a file named .github/workflows/deploy.yml in your project’s root directory and paste the following code:

name: Build and Deploy to CapRover

on:
  push:
    branches:
      - main # Triggered only when pushing to the main branch

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

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build and Push Docker Image
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: ${{ secrets.DOCKERHUB_USERNAME }}/your-repo-name:latest

      - name: Deploy to CapRover
        uses: caprover/deploy-from-github@v1.1.2
        with:
          server: ${{ secrets.CAPROVER_SERVER }}
          app: 'your-caprover-app-name' # The app name defined in CapRover
          token: ${{ secrets.CAPROVER_APP_TOKEN }}
          image: ${{ secrets.DOCKERHUB_USERNAME }}/your-repo-name:latest

Test the Pipeline

You’re all set! Now, make a small change in your code and push it to GitHub:

1. Code Pushed: GitHub Actions is triggered immediately.
2. Docker Build: Your project is dockerized and pushed to your Docker Hub repository.
3. CapRover Signal: GitHub sends a signal to your CapRover server notifying it that a new image is ready.
4. Live Update: CapRover pulls the new image and updates your application with zero downtime.

Important Note: Using Private Repositories

If your Docker Hub repository is Private, CapRover needs permission to pull the image. To fix this, go to Cluster > Remote Registry in your CapRover dashboard and add your Docker Hub credentials once.