Add devel/staging staged-publishing flow, rename default branch to main

- .gitea/workflows/build-deploy.yml: trigger on [main, staging, devel];
  build step picks publishconf.py (main) / stagingconf.py (staging) /
  bare pelicanconf.py (devel, same as a plain local build); deploy
  step already had prod-vs-test branching, updated its ref check from
  master to main to match the repo's renamed default branch.
- stagingconf.py: new, prod-like preview config (feeds, absolute URLs)
  pointed at the internal dev webserver instead of the real domain.
- pelicanconf.py: SITEURL set to the dev webserver address (was ''),
  used by both stagingconf.py and bare devel builds.
This commit is contained in:
2026-08-14 10:54:33 +00:00
parent 4c40c68014
commit d73f275c31
3 changed files with 75 additions and 8 deletions
+53 -7
View File
@@ -2,7 +2,7 @@ name: Build and deploy
on: on:
push: push:
branches: [master] branches: [main, staging, devel]
workflow_dispatch: {} workflow_dispatch: {}
jobs: jobs:
@@ -27,12 +27,23 @@ jobs:
# directly from a known_hosts file that already trusts both hosts) # directly from a known_hosts file that already trusts both hosts)
# rather than fetched via ssh-keyscan — no extra network calls, no # rather than fetched via ssh-keyscan — no extra network calls, no
# TOFU, and no risk of tripping aquaria's connection-rate limiting. # TOFU, and no risk of tripping aquaria's connection-rate limiting.
# KNOWN_HOSTS is shared between prod/test (just more lines in the
# same blob); the deploy key itself picks PROD_/TEST_ by branch,
# each falling back to the generic DEPLOY_SSH_KEY if unset.
env: env:
REF_NAME: ${{ github.ref_name }}
PROD_DEPLOY_SSH_KEY: ${{ secrets.PROD_DEPLOY_SSH_KEY }}
TEST_DEPLOY_SSH_KEY: ${{ secrets.TEST_DEPLOY_SSH_KEY }}
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
KNOWN_HOSTS: ${{ vars.KNOWN_HOSTS }} KNOWN_HOSTS: ${{ vars.KNOWN_HOSTS }}
run: | run: |
if [ "$REF_NAME" = "main" ]; then
KEY="${PROD_DEPLOY_SSH_KEY:-$DEPLOY_SSH_KEY}"
else
KEY="${TEST_DEPLOY_SSH_KEY:-$DEPLOY_SSH_KEY}"
fi
mkdir -p ~/.ssh mkdir -p ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key printf '%s\n' "$KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key
printf '%s\n' "$KNOWN_HOSTS" >> ~/.ssh/known_hosts printf '%s\n' "$KNOWN_HOSTS" >> ~/.ssh/known_hosts
@@ -45,15 +56,50 @@ jobs:
run: pip install --no-cache-dir -r requirements.txt run: pip install --no-cache-dir -r requirements.txt
- name: Build site - name: Build site
run: pelican -s publishconf.py # main -> real prod config; staging -> prod-like preview (feeds,
# absolute URLs) pointed at the dev webserver; devel (or anything
# else) -> bare pelicanconf.py, same as a plain local build.
env:
REF_NAME: ${{ github.ref_name }}
run: |
if [ "$REF_NAME" = "main" ]; then
pelican -s publishconf.py
elif [ "$REF_NAME" = "staging" ]; then
pelican -s stagingconf.py
else
pelican
fi
- name: Deploy via rsync - name: Deploy via rsync
# main -> production, anything else (i.e. devel/staging) -> test. Host is
# required per-target (no generic fallback); port/path/user each
# fall back to a shared generic var/secret, then (port only) 22.
env: env:
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }} REF_NAME: ${{ github.ref_name }}
PROD_DEPLOY_HOST: ${{ vars.PROD_DEPLOY_HOST }}
TEST_DEPLOY_HOST: ${{ vars.TEST_DEPLOY_HOST }}
PROD_DEPLOY_PORT: ${{ vars.PROD_DEPLOY_PORT }}
TEST_DEPLOY_PORT: ${{ vars.TEST_DEPLOY_PORT }}
DEPLOY_PORT: ${{ vars.DEPLOY_PORT }} DEPLOY_PORT: ${{ vars.DEPLOY_PORT }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }} PROD_DEPLOY_PATH: ${{ vars.PROD_DEPLOY_PATH }}
TEST_DEPLOY_PATH: ${{ vars.TEST_DEPLOY_PATH }}
DEPLOY_PATH: ${{ vars.DEPLOY_PATH }} DEPLOY_PATH: ${{ vars.DEPLOY_PATH }}
PROD_DEPLOY_USER: ${{ secrets.PROD_DEPLOY_USER }}
TEST_DEPLOY_USER: ${{ secrets.TEST_DEPLOY_USER }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
run: | run: |
if [ "$REF_NAME" = "main" ]; then
HOST="$PROD_DEPLOY_HOST"
PORT="${PROD_DEPLOY_PORT:-$DEPLOY_PORT}"
DPATH="${PROD_DEPLOY_PATH:-$DEPLOY_PATH}"
USER_="${PROD_DEPLOY_USER:-$DEPLOY_USER}"
else
HOST="$TEST_DEPLOY_HOST"
PORT="${TEST_DEPLOY_PORT:-$DEPLOY_PORT}"
DPATH="${TEST_DEPLOY_PATH:-$DEPLOY_PATH}"
USER_="${TEST_DEPLOY_USER:-$DEPLOY_USER}"
fi
echo "Deploying $REF_NAME -> $HOST"
rsync -avz --delete \ rsync -avz --delete \
-e "ssh -4 -i ~/.ssh/deploy_key -p ${DEPLOY_PORT:-22} -o StrictHostKeyChecking=yes" \ -e "ssh -4 -i ~/.ssh/deploy_key -p ${PORT:-22} -o StrictHostKeyChecking=yes" \
output/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}" output/ "${USER_}@${HOST}:${DPATH}"
+1 -1
View File
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
AUTHOR = 'haemka' AUTHOR = 'haemka'
SITENAME = '[hɐəmkɑ]' SITENAME = '[hɐəmkɑ]'
SITEURL = '' SITEURL = 'http://haemka-de.wd.haemka.lan'
TIMEZONE = 'Europe/Berlin' TIMEZONE = 'Europe/Berlin'
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
# Used for the "staging" branch build: a more production-like preview
# than the bare pelicanconf.py build used for "devel" (feeds enabled,
# absolute URLs) but still pointed at the internal dev webserver rather
# than the real domain.
import os
import sys
sys.path.append(os.curdir)
from pelicanconf import *
SITEURL = 'http://haemka-de.wd.haemka.lan'
RELATIVE_URLS = False
FEED_ALL_ATOM = 'feeds/all.atom.xml'
CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
DELETE_OUTPUT_DIRECTORY = True