Files
poweronoff.click/.gitea/workflows/build.yml
T
morpheus c378349cff
Build and deploy the poweronoff.click hugo / build (push) Successful in 43s
Build with the latest Hugo instead of a pinned release
Use ghcr.io/gohugoio/hugo:latest in CI and locally, so the site always builds
with the current Hugo release (currently v0.169.0). HUGO_IMAGE stays overridable
for debugging a version regression.

Trade-off: builds are no longer reproducible. If an upstream release breaks the
build, pin HUGO_IMAGE locally, then bump PaperMod with `make theme-update`.
2026-11-06 10:29:33 +01:00

88 lines
3.2 KiB
YAML

name: Build and deploy the poweronoff.click hugo
on:
push:
branches:
- master
pull_request:
# Serialise deploys per ref so two quick pushes cannot publish out of order.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
# The image runs as a non-root user, so the mounted workspace must be
# writable. Same tag as the Makefile: `latest`, so site builds always use
# the newest Hugo. Pin a tag here only to debug a version regression.
- name: Prepare workspace
run: chmod -R a+rwX .
- name: Build
uses: docker://ghcr.io/gohugoio/hugo:latest
with:
args: --minify
# rsync keeps the webroot an exact mirror of public/, so deleted or
# renamed pages disappear from the server too (scp with rm:false used to
# leave them behind forever). It is incremental: a failed transfer never
# wipes the live site. Password auth is kept for now; switching to an SSH
# key is a follow-up.
- name: Install deploy tools
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
SUDO=""
if command -v sudo >/dev/null 2>&1; then SUDO=sudo; fi
$SUDO apt-get update -qq
$SUDO apt-get install -y -qq rsync sshpass
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
SSH_PORT: ${{ secrets.SSH_PORT }}
DEPLOY_HOST: poweronoff.click
DEPLOY_PATH: /var/www/poweronoff.click
run: |
set -euo pipefail
port="${SSH_PORT:-22}"
mkdir -p ~/.ssh
ssh-keyscan -p "$port" -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null
# -rlptz preserves the Hugo output permissions/timestamps
# --delete: remove files that no longer exist in public/
# --delay-updates: swap in the new files last, so visitors never see a
# half-synced site
# .well-known is excluded so ACME/other challenges survive a deploy
export SSHPASS="$SSH_PASSWORD"
sshpass -e rsync -rlptz \
--delete --delay-updates \
--exclude='.well-known/' \
-e "ssh -p $port -o StrictHostKeyChecking=yes" \
public/ "$SSH_USERNAME@$DEPLOY_HOST:$DEPLOY_PATH/"
- name: Verify deployment
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: curl -fsS --retry 5 --retry-delay 3 --retry-connrefused https://poweronoff.click/ -o /dev/null
- name: Send Telegram notification
if: always() && github.event_name == 'push'
uses: appleboy/telegram-action@v0.1.1
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
${{ github.repository }} — ${{ job.status }}
Commit: ${{ github.event.head_commit.message }}
${{ github.event.head_commit.url }}