31c8351b6b
Requires a self-hosted runner and repo secrets (DEPLOY_HOST, DEPLOY_USER, DEPLOY_PATH, DEPLOY_SSH_KEY) to be set up before it will actually run.
45 lines
1.4 KiB
YAML
45 lines
1.4 KiB
YAML
name: Build and deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
workflow_dispatch: {}
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
# Needs a self-hosted Gitea Actions runner with this label registered
|
|
# against git.haemka.in — none exists yet, set one up before enabling this.
|
|
runs-on: self-hosted
|
|
container: python:3.12-slim
|
|
steps:
|
|
- name: Install system dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y --no-install-recommends git rsync openssh-client
|
|
|
|
- name: Checkout (incl. theme submodule)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Install Python dependencies
|
|
run: pip install --no-cache-dir -r requirements.txt
|
|
|
|
- name: Build site
|
|
run: pelican -s publishconf.py
|
|
|
|
- name: Deploy via rsync
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
|
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key
|
|
chmod 600 ~/.ssh/deploy_key
|
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null
|
|
rsync -avz --delete \
|
|
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=yes" \
|
|
output/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}"
|