black and white penguin toy

Automatic deployments from Github to Caprover

An easy way to deploy your GitHub repository to Caprover every time your main branch is updated.

First, you need to set up the Caprover password in Github. Go to Secrets and create a new repository secret. Name it “CAPROVER_PASSWORD” and use your Caprover account password.

A screenshot of Github Secrets page

Create a file to .github/workflows/deploy.yml and paste the following contents. Make sure to change PATH_TO_CAPROVER, YOUR_APP_NAME and possibly your branch name.

name: Create and publish a Docker image to Caprover

on:
  push:
    branches: ['master']

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Set up npm
        uses: actions/setup-node@v2
        with:
          node-version: '14'

      - name: Install caprover
        run: npm install -g caprover

      - name: Caprover Deploy
        run: caprover deploy -h 'https://PATH_TO_CAPROVER' -p '${{ secrets.CAPROVER_PASSWORD }}' -b 'master' -a 'YOUR_APP_NAME'

Credits to this comment

Commit and push changes. Next time you merge something to master, your site should be deployed.

A screenshot of Github Actions