Deploy hugo to vps with cpanel?

Hi there,

What is the best option to let github build pages and deploy to cpanel automatically. something like this:

name: Daily Build and Deploy

on:
  schedule:
    - cron: '0 0 * * *'  # Trigger every day at midnight UTC

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: 'latest'

      - name: Build Hugo site
        run: hugo --minify

      - name: Upload to cPanel
        uses: appleboy/scp-action@v0.4.0
        with:
          host: ${{ secrets.CPANEL_HOST }}
          username: ${{ secrets.CPANEL_USERNAME }}
          key: ${{ secrets.CPANEL_SSH_KEY }}
          source: 'public/'
          target: '/path/to/cpanel/website/public_html/'

have someone already did this and might have the things to note, best practices etc for deploying hugo site to cpanel?

Thanks

This should work for any host where you have ssh/scp access. If the host is running cpanel or not has really no part in it.

The example above are using old versions of some actions, recommend you update to latest versions.

  • actions/checkout@v4
  • appleboy/scp-action@v0.1.4
2 Likes