Add deploy-static reusable workflow

This commit is contained in:
2026-06-20 19:29:27 -04:00
commit 2f36faed6b
+78
View File
@@ -0,0 +1,78 @@
name: Deploy static site to devfarm
# Reusable workflow: installs, builds, and rsyncs dist output to the
# devsites share so Caddy serves it at <site>.dev.clubbabyseal.com.
#
# Usage in a caller workflow:
# jobs:
# deploy:
# uses: ringmaster/tower/.gitea/workflows/deploy-static.yml@main
# with:
# site: myapp # → https://myapp.dev.clubbabyseal.com
# build-command: npm run build
#
# See docs/deploy-static.md for full reference.
on:
workflow_call:
inputs:
site:
description: >
Subdomain / folder name under /mnt/user/devsites/. The built output
lands in /mnt/user/devsites/<site>/dist/ and is served at
https://<site>.dev.clubbabyseal.com by Caddy.
required: true
type: string
install-command:
description: Dependency install command. Set to empty string to skip.
required: false
default: npm ci
type: string
build-command:
description: Command that produces the dist/ output.
required: false
default: npm run build
type: string
dist-dir:
description: Build output directory (relative to working-directory).
required: false
default: dist
type: string
working-directory:
description: Directory to run install and build in.
required: false
default: .
type: string
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
if: inputs.install-command != ''
working-directory: ${{ inputs.working-directory }}
run: ${{ inputs.install-command }}
- name: Build
working-directory: ${{ inputs.working-directory }}
run: ${{ inputs.build-command }}
- name: Deploy to devfarm
run: |
SITE="${{ inputs.site }}"
SRC="${{ inputs.working-directory }}/${{ inputs.dist-dir }}"
TARGET="/mnt/user/devsites/${SITE}/dist"
# Validate site name: alphanumeric + hyphens only, no path traversal.
if ! echo "$SITE" | grep -qE '^[a-z0-9-]+$'; then
echo "ERROR: site name must match [a-z0-9-]+"
exit 1
fi
mkdir -p "$TARGET"
rsync -a --delete "${SRC}/" "${TARGET}/"
echo "Deployed $SRC → $TARGET"
echo "Live at: https://${SITE}.dev.clubbabyseal.com"