08/02/2024, 24:00
GitHub Actions → Nginx static deploy
Here is the minimal flow that keeps the origin server simple:
- Push changes or new Markdown.
- GitHub Actions runs
npm ci && npm run build. - Upload
dist/to/var/www/portfolioon the domestic server viarsyncorscp. - Nginx serves the static directory—no Node runtime, no database.
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 build
- uses: easingthemes/ssh-deploy@v5.0.0
with:
remote_dir: /var/www/portfolio
source: dist/
You can extend this to sync a CDN in front, but the core idea is to keep deployments predictable and observable.