name: Deploy static site to devfarm # Reusable workflow: installs, builds, and deploys dist output to the # devsites share so Caddy serves it at .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//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 container: image: gitea/runner-images:ubuntu-latest volumes: - /mnt/user/devsites:/mnt/user/devsites 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"