78 lines
2.4 KiB
YAML
78 lines
2.4 KiB
YAML
name: Deploy static site to devfarm
|
|
|
|
# Reusable workflow: installs, builds, and deploys dist output to the
|
|
# devsites share so Caddy serves it at <site>.dev.clubbabyseal.com.
|
|
#
|
|
# Usage in a caller workflow:
|
|
# jobs:
|
|
# deploy:
|
|
# uses: ringmaster/actions/.gitea/workflows/deploy-static.yml@main
|
|
# with:
|
|
# site: myapp # → https://myapp.dev.clubbabyseal.com
|
|
# build-command: npm run build
|
|
|
|
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"
|
|
rm -rf "${TARGET:?}/"* 2>/dev/null || true
|
|
cp -a "${SRC}/." "${TARGET}/"
|
|
echo "Deployed $SRC → $TARGET"
|
|
echo "Live at: https://${SITE}.dev.clubbabyseal.com"
|