From 2f36faed6ba9f42ee395fce9cfb856e200437c3f Mon Sep 17 00:00:00 2001 From: Owen Winkler Date: Sat, 20 Jun 2026 19:29:27 -0400 Subject: [PATCH] Add deploy-static reusable workflow --- .gitea/workflows/deploy-static.yml | 78 ++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .gitea/workflows/deploy-static.yml diff --git a/.gitea/workflows/deploy-static.yml b/.gitea/workflows/deploy-static.yml new file mode 100644 index 0000000..f28f9d6 --- /dev/null +++ b/.gitea/workflows/deploy-static.yml @@ -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 .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//dist/ and is served at + https://.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"