ci(polaris)!: 改为仅在版本标签触发工作流

将运行提示改为中文,移除旧的 runner 冒烟测试工作流。

BREAKING CHANGE: main 分支提交不再触发 Polaris CI。
This commit is contained in:
2026-10-13 14:18:42 +08:00
parent fec2a97936
commit d53dbac88e
2 changed files with 32 additions and 52 deletions
+32 -35
View File
@@ -2,11 +2,8 @@ name: Polaris CI
on:
push:
branches:
- main
paths:
- ts/web/nextjs/polaris/**
- .gitea/workflows/polaris-ci.yml
tags:
- 'polaris-v*'
jobs:
verify:
@@ -17,31 +14,31 @@ jobs:
run:
working-directory: ts/web/nextjs/polaris
steps:
- name: Check out repository
- name: 检出仓库
uses: https://gitea.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install dependencies
- name: 安装依赖
run: corepack pnpm install --frozen-lockfile
- name: Lint
- name: 代码检查
run: corepack pnpm lint
- name: Typecheck
- name: 类型检查
run: corepack pnpm typecheck
- name: Test
- name: 运行测试
run: corepack pnpm test
- name: Build standalone server
- name: 构建独立服务器
run: corepack pnpm build
- name: Prepare standalone output
- name: 准备独立部署文件
run: |
test -f .next/standalone/server.js
cp -r public .next/standalone/
cp -r .next/static .next/standalone/.next/
- name: Smoke test standalone server
- name: 独立服务器冒烟测试
shell: bash
run: |
set -euo pipefail
@@ -56,32 +53,32 @@ jobs:
ready=1
break
fi
kill -0 "$server_pid" 2>/dev/null || { echo "server process exited early" >&2; exit 1; }
kill -0 "$server_pid" 2>/dev/null || { echo "服务器进程提前退出" >&2; exit 1; }
sleep 1
done
test "$ready" -eq 1 || { echo "server not ready within 30s" >&2; exit 1; }
test "$ready" -eq 1 || { echo "服务器在 30 秒内未就绪" >&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; }
test -n "$static_asset" || { echo "首页未引用 /_next/static 静态资源" >&2; exit 1; }
curl -fsS -o /dev/null "$base_url$static_asset"
publish:
needs: verify
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/polaris-v')
runs-on: polaris-ci
container: node:22.23.2-bookworm
timeout-minutes: 30
steps:
- name: Check out repository
- name: 检出仓库
uses: https://gitea.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
# Daemon comes from the runner (gitea/runner:3-dind-rootless) via the
# job container's /var/run/docker.sock. Only the CLI is installed here;
# DOCKER_HOST stays unset and no host socket is mounted.
- name: Install Docker CLI
- name: 安装 Docker 命令行工具
run: |
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
@@ -89,25 +86,25 @@ jobs:
apt-get install -y --no-install-recommends docker.io
docker version
- name: Resolve image reference
- name: 确定镜像引用
shell: bash
run: |
set -euo pipefail
repository="${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is not set}"
repository="${GITHUB_REPOSITORY:?未设置 GITHUB_REPOSITORY}"
owner="${repository%%/*}"
owner="${owner,,}"
if ! [[ "$owner" =~ ^[a-z0-9]([a-z0-9._-]*[a-z0-9])?$ ]]; then
echo "::error::owner segment '$owner' is not a valid registry path component" >&2
echo "::error::所有者名称 '$owner' 不是有效的镜像仓库路径组成部分" >&2
exit 1
fi
image="git.labmem.icu/${owner}/polaris:${GITHUB_SHA}"
echo "image reference: $image"
echo "镜像引用:$image"
echo "IMAGE=$image" >> "$GITHUB_ENV"
- name: Build image
- name: 构建镜像
run: docker build -t "$IMAGE" ts/web/nextjs/polaris
- name: Smoke test image
- name: 镜像冒烟测试
shell: bash
run: |
set -euo pipefail
@@ -128,19 +125,19 @@ jobs:
break
fi
if [[ "$(docker inspect -f '{{.State.Running}}' "$container")" != "true" ]]; then
echo "container exited early, logs:" >&2
echo "容器提前退出,日志:" >&2
docker logs "$container" >&2 || true
exit 1
fi
sleep 1
done
test "$ready" -eq 1 || { echo "server not ready within 30s" >&2; docker logs "$container" >&2 || true; exit 1; }
test "$ready" -eq 1 || { echo "服务器在 30 秒内未就绪" >&2; docker logs "$container" >&2 || true; exit 1; }
probe /categories/dev/ || { echo "smoke test failed: /categories/dev/" >&2; exit 1; }
probe /brand/logo.svg || { echo "smoke test failed: /brand/logo.svg" >&2; exit 1; }
echo "smoke test passed for $IMAGE"
probe /categories/dev/ || { echo "冒烟测试失败:/categories/dev/" >&2; exit 1; }
probe /brand/logo.svg || { echo "冒烟测试失败:/brand/logo.svg" >&2; exit 1; }
echo "镜像 $IMAGE 冒烟测试通过"
- name: Log in and push image
- name: 登录并推送镜像
shell: bash
env:
POLARIS_REGISTRY_USER: ${{ secrets.POLARIS_REGISTRY_USER }}
@@ -160,7 +157,7 @@ jobs:
printf '%s' "$POLARIS_REGISTRY_TOKEN" | docker --config "$docker_config_dir" login git.labmem.icu --username "$POLARIS_REGISTRY_USER" --password-stdin >/dev/null
echo "pushing $IMAGE"
echo "正在推送 $IMAGE"
# tee keeps push output visible in the log; pipefail (already set
# via `set -euo pipefail`) fails the step when push itself fails.
docker --config "$docker_config_dir" push "$IMAGE" 2>&1 | tee "$push_log_file"
@@ -171,6 +168,6 @@ jobs:
exit 1
fi
echo "published image: $IMAGE"
echo "digest: $digest"
echo "manual deploy reference: docker pull ${IMAGE%%:*}@$digest"
echo "已发布镜像:$IMAGE"
echo "镜像摘要:$digest"
echo "手动部署引用:docker pull ${IMAGE%%:*}@$digest"
-17
View File
@@ -1,17 +0,0 @@
name: Polaris runner smoke test
on:
push:
branches:
- main
paths:
- .gitea/workflows/polaris-runner-smoke.yml
jobs:
smoke:
runs-on: polaris-ci
steps:
- name: Confirm runner can execute a job
run: |
echo "Polaris runner is working"
uname -m