name: Build site with Hugo description: >- Installs the requested Hugo version and builds the site into public/. Optionally serves the result, which the quality gates need. inputs: version: description: Hugo version to install, without a leading "v" (e.g. "0.154.5"). required: true args: description: Full argument list for `hugo`; setting it drops the default --gc --minify. required: false default: --gc --minify serve-port: description: Port to serve public/ on. Needs http-server in the job image. Empty means do not serve. required: false default: '' runs: using: composite steps: - uses: peaceiris/actions-hugo@v3 with: hugo-version: ${{ inputs.version }} extended: true - name: Build shell: bash env: ARGS: ${{ inputs.args }} # ARGS stays unquoted on purpose - it carries a list of arguments, not a single one. run: hugo ${ARGS} # Polling beats a fixed sleep: the gates fail with "no FCP" when they start before the # server is up, and that failure reads like a site problem. - name: Serve built site if: inputs.serve-port != '' shell: bash env: SERVE_PORT: ${{ inputs.serve-port }} run: | command -v http-server >/dev/null || { echo "http-server is not installed in the job image." >&2; exit 1; } # Server output goes to a file, not to the step pipe: a background process keeps stdout # open and the runner then waits for EOF long after the audit is done (run 2145). http-server public -p "${SERVE_PORT}" --silent > /tmp/http-server.log 2>&1 & for _ in $(seq 1 60); do if curl -sfo /dev/null "http://localhost:${SERVE_PORT}/"; then exit 0 fi sleep 1 done echo "http-server did not come up on port ${SERVE_PORT} within 60s." >&2 exit 1