Files
blog/.gitea/workflows/build-and-deploy.yaml
daniel f6b3e50f4f
Build and Deploy / build-and-deploy (push) Has been cancelled
Use latest versions of modules.
2026-06-14 23:19:57 +02:00

57 lines
1.5 KiB
YAML

name: Build and Deploy
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: self-hosted
container:
image: ghcr.io/gohugoio/hugo:latest
options: --user root
env:
HUGO_ENVIRONMENT: production
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true # Required if your theme is a Git submodule
fetch-depth: 0 # Hugo uses full history for .GitInfo and lastmod
- name: Install Sass
run: |
npm install sass
- name: Install and update modules
run: hugo mod get -u
- name: Build site
run: hugo --minify
- name: Install rsync and openssh-client
run: |
apk add --no-cache rsync openssh-client
# Hugo's official image is Alpine-based; use apk.
# If a Debian-based Hugo image is used, swap to:
# apt-get update && apt-get install -y rsync openssh-client
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "${{ secrets.DEPLOY_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Deploy via rsync
run: |
rsync -avz --delete \
-e "ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes" \
public/ \
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:/${{ secrets.DEPLOY_SUBDIR }}