Files
xiaoxia-saas/scripts/ci/ci_push_paths.sh
T
xiaoxia ef09338098
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 3m16s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 3m26s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 3m46s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 4m48s
CI/CD Pipeline / Check push changed paths (push) Successful in 5m18s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m10s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 3m39s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 40s
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 / ACR Image Cleanup (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m30s
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 41s
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 / Validate - Code Quality (push) Successful in 9m4s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 39s
CI/CD Pipeline / Retag skipped Staging API Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 9m6s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 5m25s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 9m36s
AI Code Review / AI Code Review (pull_request) Successful in 6m32s
CI/CD Pipeline / Retag skipped Staging Web Image (push) Successful in 59s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m9s
CI/CD Pipeline / Integration Tests (push) Successful in 3m23s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 2m24s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m11s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 4m7s
CI/CD Pipeline / Unit Tests (push) Successful in 16m45s
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 12m58s
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) Successful in 25s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 7m40s
fix(ci): push 路径检测改用 compare 响应内每提交 files 聚合 (#1539)
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
2026-08-29 15:21:06 +08:00

84 lines
2.9 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
# Gitea 1.26.x compare API 的顶层 files 字段不填充(始终为空),
# 但响应里每个 commit 条目自带的 files 完整可用;聚合区间内所有提交的 files 即可。
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)
files=set()
for c in d.get('commits', []) or []:
for f in (c.get('files') or []):
n = f.get('filename') or ''
if n:
files.add(n)
print('\n'.join(sorted(files)))
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