Automatic deployments from Github to Caprover

Here’s 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

    branches: ['master']

    runs-on: ubuntu-latest
      - name: Checkout repository
        uses: actions/checkout@v3
          fetch-depth: 0

      - name: Set up npm
        uses: actions/setup-node@v2
          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

Leave a Reply

Your email address will not be published. Required fields are marked *