Skip to content

Automated Deploy with GitHub Actions

Setting up a CI/CD pipeline doesn't have to be complicated. Here's how to automate your static site deployment on every push.

Why Automate Deployment

Manual deployment is error-prone and time-consuming. With an automated pipeline:

  • Every push to main generates a new version of the site
  • The build is tested before deployment
  • You get a complete log of every operation
  • You can add linting, testing, and validation steps

The Basic Workflow

A GitHub Actions workflow for a VitePress site looks like this:

yaml
name: Deploy

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm run docs:build

This is the bare minimum. From here you can add deployment to Cloudflare Pages, Netlify, or any other hosting provider.

Best Practices

  • Use npm ci instead of npm install for reproducible builds
  • Pin the Node.js version in the workflow
  • Add a lint job before the build
  • Use GitHub secrets for deployment keys

Made with ❤️ by PeterDev
'Ho mio cuGGGino che lo sa fare' cit.