a64037881a
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2m20s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 3m28s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 3m16s
AI Code Review / AI Code Review (pull_request) Successful in 1m59s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 2m13s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m59s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m8s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 4m45s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m8s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 9m25s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m16s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 16m45s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 28s
1. build-staging 路径过滤:纯前端改动只构建Web,纯后端只构建API/Worker; 未重建镜像通过 retag-staging-skipped job 将分支tag retag为新SHA推送,Watchtower链路不变 2. deploy-staging、acr-cleanup runs-on 从 runtime-builder 改为 ci-l2,释放构建槽 3. buildx 改为宿主机持久 builder(ci-builder-persist)+buildkit命名卷缓存, job结束不再prune,Worker镜像同样接入buildx缓存 4. validate/unit-test/frontend-test 的 pip/npm 依赖通过宿主机命名卷持久化缓存 (runner config 挂载 ci-pip-cache/xiaoxia-npm-cache/act-toolcache) 5. 不影响生产构建/发版/canary 相关 job
78 lines
2.6 KiB
Bash
Executable File
78 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# CI 公共步骤:检测 push(develop/main) 事件的改动范围
|
|
# 输出 skip_backend / skip_frontend(复用 PR check 的语义)
|
|
# - 纯前端改动(仅 apps/web/): skip_backend=true
|
|
# - 纯后端改动(不含 apps/web/): skip_frontend=true
|
|
# - 全栈 / 无法判断: 两者都 false(走全量,安全兜底)
|
|
# 需要环境变量: GITHUB_TOKEN, GITHUB_API_URL, GITHUB_REPOSITORY, GITHUB_SHA
|
|
set -eu
|
|
|
|
OUTPUT="${GITHUB_OUTPUT:-/dev/stdout}"
|
|
|
|
before="${GITHUB_EVENT_BEFORE:-}"
|
|
after="${GITHUB_SHA:-}"
|
|
repo="${GITHUB_REPOSITORY:-}"
|
|
base="${GITHUB_API_URL:-}"
|
|
|
|
# Gitea Actions 中 push 事件的前一个 SHA 在 event payload 的 before 字段
|
|
if [ -z "$before" ] && [ -n "${GITHUB_EVENT_PATH:-}" ] && [ -f "$GITHUB_EVENT_PATH" ]; then
|
|
before=$(python3 -c "
|
|
import json,sys
|
|
try:
|
|
d=json.load(open('${GITHUB_EVENT_PATH}'))
|
|
print(d.get('before','') or '')
|
|
except Exception:
|
|
print('')
|
|
")
|
|
fi
|
|
|
|
echo "改动范围检测: before=${before:-<empty>} after=${after}"
|
|
|
|
FILES=""
|
|
if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" ]; then
|
|
# compare API: {base}...{head}
|
|
API_URL="${base}/repos/${repo}/compare/${before}...${after}?per_page=300"
|
|
for attempt in 1 2 3; do
|
|
FILES=$(curl -s --max-time 30 -H "Authorization: token ${GITHUB_TOKEN}" "$API_URL" \
|
|
| python3 -c "
|
|
import json,sys
|
|
try:
|
|
d=json.load(sys.stdin)
|
|
for f in d.get('files', []):
|
|
print(f.get('filename',''))
|
|
except Exception:
|
|
pass
|
|
")
|
|
[ -n "$FILES" ] && break
|
|
echo "compare API 无返回,重试 $attempt/3..."
|
|
sleep 3
|
|
done
|
|
fi
|
|
|
|
if [ -z "$FILES" ]; then
|
|
echo "⚠️ 无法获取改动文件列表(新分支/API异常),保守起见走全量构建"
|
|
echo "skip_backend=false" >> "$OUTPUT"
|
|
echo "skip_frontend=false" >> "$OUTPUT"
|
|
exit 0
|
|
fi
|
|
|
|
TOTAL=$(printf '%s\n' "$FILES" | grep -c . || true)
|
|
FRONTEND_COUNT=$(printf '%s\n' "$FILES" | grep -c '^apps/web/' || true)
|
|
BACKEND_COUNT=$(python3 -c "print($TOTAL - $FRONTEND_COUNT)")
|
|
|
|
echo "变更文件: ${TOTAL} 个 (前端: ${FRONTEND_COUNT}, 后端/公共: ${BACKEND_COUNT})"
|
|
|
|
if [ "$BACKEND_COUNT" = "0" ] && [ "$FRONTEND_COUNT" -gt "0" ]; then
|
|
echo "skip_backend=true" >> "$OUTPUT"
|
|
echo "skip_frontend=false" >> "$OUTPUT"
|
|
echo "✅ 纯前端改动,跳过后端镜像构建"
|
|
elif [ "$FRONTEND_COUNT" = "0" ] && [ "$BACKEND_COUNT" -gt "0" ]; then
|
|
echo "skip_backend=false" >> "$OUTPUT"
|
|
echo "skip_frontend=true" >> "$OUTPUT"
|
|
echo "🔧 纯后端改动,跳过 Web 镜像构建"
|
|
else
|
|
echo "skip_backend=false" >> "$OUTPUT"
|
|
echo "skip_frontend=false" >> "$OUTPUT"
|
|
echo "🔧 包含全栈/公共变更,三个镜像全部构建"
|
|
fi
|