fix(ci): scope PR path detection to head changes

This commit is contained in:
chengyongru 2026-07-28 19:15:39 +08:00 committed by chengyongru
parent 019d7816a7
commit 9070d7489a

View File

@ -33,13 +33,20 @@ jobs:
id: paths id: paths
shell: bash shell: bash
env: env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.sha }} HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
run: | run: |
python_required=true python_required=true
if [[ "$EVENT_NAME" == "pull_request" ]]; then
diff_range="${BASE_SHA}...${HEAD_SHA}"
else
diff_range="${BASE_SHA}..${HEAD_SHA}"
fi
if git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null && if git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null &&
changed_files="$(git diff --name-only --no-renames "$BASE_SHA" "$HEAD_SHA")" && changed_files="$(git diff --name-only --no-renames "$diff_range")" &&
[[ -n "$changed_files" ]] && [[ -n "$changed_files" ]] &&
! grep -qvE '^(webui/|nanobot/channels/[^/]+/webui/|docs/)' <<< "$changed_files"; then ! grep -qvE '^(webui/|nanobot/channels/[^/]+/webui/|docs/)' <<< "$changed_files"; then
python_required=false python_required=false