This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# schedule:
|
||||
# - cron: '0 0 * * *'
|
||||
# timezone: 'Europe/Berlin'
|
||||
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: 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 }}
|
||||
Reference in New Issue
Block a user