Polaris CI / verify (push) Successful in 1m47s
将 Next.js 构建切换为 standalone,新增多阶段 Docker 镜像和非 root 运行。 CI 改为启动服务检查页面与静态资源,并移除静态导出校验。 BREAKING CHANGE: 不再生成 out/ 静态产物,部署需运行 Node 服务容器。
70 lines
2.0 KiB
YAML
70 lines
2.0 KiB
YAML
name: Polaris CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- ts/web/nextjs/polaris/**
|
|
- .gitea/workflows/polaris-ci.yml
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: polaris-ci
|
|
container: node:22.23.2-bookworm
|
|
timeout-minutes: 30
|
|
defaults:
|
|
run:
|
|
working-directory: ts/web/nextjs/polaris
|
|
steps:
|
|
- name: Check out repository
|
|
uses: https://gitea.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
|
|
|
- name: Install dependencies
|
|
run: corepack pnpm install --frozen-lockfile
|
|
|
|
- name: Lint
|
|
run: corepack pnpm lint
|
|
|
|
- name: Typecheck
|
|
run: corepack pnpm typecheck
|
|
|
|
- name: Test
|
|
run: corepack pnpm test
|
|
|
|
- name: Build standalone server
|
|
run: corepack pnpm build
|
|
|
|
- name: Prepare standalone output
|
|
run: |
|
|
test -f .next/standalone/server.js
|
|
cp -r public .next/standalone/
|
|
cp -r .next/static .next/standalone/.next/
|
|
|
|
- name: Smoke test standalone server
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
base_url="http://127.0.0.1:3100"
|
|
PORT=3100 HOSTNAME=127.0.0.1 node .next/standalone/server.js &
|
|
server_pid=$!
|
|
trap 'kill "$server_pid" 2>/dev/null || true' EXIT
|
|
|
|
ready=0
|
|
for _ in $(seq 1 30); do
|
|
if curl -fsS -o /dev/null "$base_url/"; then
|
|
ready=1
|
|
break
|
|
fi
|
|
kill -0 "$server_pid" 2>/dev/null || { echo "server process exited early" >&2; exit 1; }
|
|
sleep 1
|
|
done
|
|
test "$ready" -eq 1 || { echo "server not ready within 30s" >&2; exit 1; }
|
|
|
|
curl -fsS -o /dev/null "$base_url/categories/dev/"
|
|
curl -fsS -o /dev/null "$base_url/brand/logo.svg"
|
|
|
|
static_asset=$(curl -fsS "$base_url/" | grep -o '/_next/static/[^"]*' | sed -n '1p')
|
|
test -n "$static_asset" || { echo "homepage references no /_next/static asset" >&2; exit 1; }
|
|
curl -fsS -o /dev/null "$base_url$static_asset"
|