fix(ci): push 路径检测改用 compare 响应内每提交 files 聚合 #1539
@@ -940,7 +940,7 @@ jobs:
|
||||
|
||||
retag-staging-skipped:
|
||||
name: Retag skipped Staging ${{ matrix.service_display }} Image
|
||||
runs-on: runtime-builder
|
||||
runs-on: ci-l2
|
||||
timeout-minutes: 10
|
||||
needs:
|
||||
- check-push-paths
|
||||
@@ -1029,7 +1029,9 @@ jobs:
|
||||
- check-push-paths
|
||||
- build-staging
|
||||
- retag-staging-skipped
|
||||
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'develop')
|
||||
# 显式 success() 状态检查:上游 build/retag 被路径过滤 if 跳过(skipped)时不阻塞本 job;
|
||||
# 上游真正失败时仍然阻断(act_runner 对无状态函数的 if 隐式包 success(),纯 skipped 也会连带跳过)
|
||||
if: success() && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'develop')
|
||||
steps:
|
||||
- name: Checkout code
|
||||
shell: sh
|
||||
@@ -1180,7 +1182,7 @@ jobs:
|
||||
name: Staging E2E Tests
|
||||
runs-on: runtime-builder
|
||||
timeout-minutes: 15
|
||||
if: github.ref_name == 'develop' || github.ref_name == 'main'
|
||||
if: success() && (github.ref_name == 'develop' || github.ref_name == 'main')
|
||||
needs: deploy-staging
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -1227,7 +1229,7 @@ jobs:
|
||||
name: Staging API Integration Tests
|
||||
runs-on: runtime-builder
|
||||
timeout-minutes: 10
|
||||
if: github.ref_name == 'develop' || github.ref_name == 'main'
|
||||
if: success() && (github.ref_name == 'develop' || github.ref_name == 'main')
|
||||
needs: deploy-staging
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
||||
@@ -30,7 +30,8 @@ echo "改动范围检测: before=${before:-<empty>} after=${after}"
|
||||
|
||||
FILES=""
|
||||
if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" ]; then
|
||||
# compare API: {base}...{head}
|
||||
# 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" \
|
||||
@@ -38,8 +39,13 @@ if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000"
|
||||
import json,sys
|
||||
try:
|
||||
d=json.load(sys.stdin)
|
||||
for f in d.get('files', []):
|
||||
print(f.get('filename',''))
|
||||
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
|
||||
")
|
||||
@@ -62,11 +68,11 @@ BACKEND_COUNT=$(python3 -c "print($TOTAL - $FRONTEND_COUNT)")
|
||||
|
||||
echo "变更文件: ${TOTAL} 个 (前端: ${FRONTEND_COUNT}, 后端/公共: ${BACKEND_COUNT})"
|
||||
|
||||
if [ "$BACKEND_COUNT" = "0" ] && [ "$FRONTEND_COUNT" -gt "0" ]; then
|
||||
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
|
||||
elif [ "$FRONTEND_COUNT" = "0" ] && [ "$BACKEND_COUNT" -gt 0 ]; then
|
||||
echo "skip_backend=false" >> "$OUTPUT"
|
||||
echo "skip_frontend=true" >> "$OUTPUT"
|
||||
echo "🔧 纯后端改动,跳过 Web 镜像构建"
|
||||
|
||||
Reference in New Issue
Block a user