针对 TEST 流水线,不检查文件变更,默认更新所有
This commit is contained in:
@@ -138,9 +138,6 @@ steps:
|
|||||||
- name: configs_dir
|
- name: configs_dir
|
||||||
path: /bluetti/frontend_project/bluetti-shop-configs
|
path: /bluetti/frontend_project/bluetti-shop-configs
|
||||||
environment:
|
environment:
|
||||||
DRONE_COMMIT: ${DRONE_COMMIT}
|
|
||||||
DRONE_COMMIT_BEFORE: ${DRONE_COMMIT_BEFORE}
|
|
||||||
DRONE_COMMIT_AFTER: ${DRONE_COMMIT_AFTER}
|
|
||||||
DOCKER_BUILDKIT: "1"
|
DOCKER_BUILDKIT: "1"
|
||||||
COMPOSE_DOCKER_CLI_BUILD: "1"
|
COMPOSE_DOCKER_CLI_BUILD: "1"
|
||||||
PROJECT_NAME:
|
PROJECT_NAME:
|
||||||
@@ -148,50 +145,10 @@ steps:
|
|||||||
# SHOP_AU: shop-test-au.bluettipower.com
|
# SHOP_AU: shop-test-au.bluettipower.com
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
# 1. 路径变动检测逻辑
|
|
||||||
if [ "${DRONE_COMMIT_BEFORE}" = "0000000000000000000000000000000000000000" ]; then
|
|
||||||
changed_files=$(git diff-tree --no-commit-id --name-only -r ${DRONE_COMMIT_AFTER})
|
|
||||||
else
|
|
||||||
changed_files=$(git diff --name-only ${DRONE_COMMIT_BEFORE} ${DRONE_COMMIT_AFTER})
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. 判断构建范围
|
|
||||||
echo "本次变更文件:"
|
|
||||||
echo "$changed_files"
|
|
||||||
|
|
||||||
full_build_changes=$(echo "$changed_files" | grep -E "^(package\.json|pnpm-lock\.yaml|.dockerignore|pnpm-workspace\.yaml|turbo\.json|docker-compose.*|packages/|patches/)" | wc -l)
|
|
||||||
PROJECT_NAME_TEST="${PROJECT_NAME}test"
|
PROJECT_NAME_TEST="${PROJECT_NAME}test"
|
||||||
COMPOSE_FILE="docker-compose-test.yml"
|
COMPOSE_FILE="docker-compose-test.yml"
|
||||||
if [ "$full_build_changes" -gt 0 ]; then
|
build_list=$(docker compose -f "$COMPOSE_FILE" config --services)
|
||||||
echo "检测到关键共享变动,准备全量构建..."
|
echo "准备构建并启动 docker-compose 中定义的所有服务: $build_list"
|
||||||
build_list=$(docker compose -f "$COMPOSE_FILE" config --services)
|
|
||||||
else
|
|
||||||
echo "执行定向增量构建..."
|
|
||||||
build_list=$(echo "$changed_files" | grep "^apps/" | cut -d/ -f2 | sort -u)
|
|
||||||
fi
|
|
||||||
|
|
||||||
compose_services=$(docker compose -f "$COMPOSE_FILE" config --services)
|
|
||||||
original_build_list="$build_list"
|
|
||||||
build_list=""
|
|
||||||
skipped_list=""
|
|
||||||
for svc in $original_build_list; do
|
|
||||||
if echo "$compose_services" | grep -q "^$svc$"; then
|
|
||||||
build_list="$build_list $svc"
|
|
||||||
else
|
|
||||||
skipped_list="$skipped_list $svc"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
build_list=$(echo "$build_list" | xargs)
|
|
||||||
skipped_list=$(echo "$skipped_list" | xargs)
|
|
||||||
|
|
||||||
if [ -n "$skipped_list" ]; then
|
|
||||||
echo "以下 apps 变更未在 docker-compose 中定义,已跳过: $skipped_list"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$build_list" ]; then
|
|
||||||
echo "未命中可构建服务(仅文档或非关键文件改动),跳过构建。"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
export BUILD_ENV="test"
|
export BUILD_ENV="test"
|
||||||
for svc in $build_list; do
|
for svc in $build_list; do
|
||||||
|
|||||||
Reference in New Issue
Block a user