@@ -33,16 +33,64 @@ jobs:
3333 fetch-depth : 0 # Need full history for proper change detection
3434
3535 - name : Detect changes in example-related files
36- uses : dorny/paths-filter@v2
3736 id : changes
38- with :
39- filters : |
40- examples:
41- - 'examples/**'
42- - 'docs/conf.py'
43- - 'scripts/download_auto_examples.py'
44- - 'requirements*.txt'
45- - '.github/workflows/generate-examples.yml'
37+ run : |
38+ echo "Detecting changes in example-related files..."
39+
40+ # Define paths to monitor
41+ PATHS=(
42+ "examples/"
43+ "docs/conf.py"
44+ "scripts/download_auto_examples.py"
45+ "requirements*.txt"
46+ ".github/workflows/generate-examples.yml"
47+ )
48+
49+ # Initialize changed flag
50+ EXAMPLES_CHANGED="false"
51+
52+ if [ "${{ github.event_name }}" = "pull_request" ]; then
53+ # For PRs, compare against the base branch
54+ BASE_SHA="${{ github.event.pull_request.base.sha }}"
55+ HEAD_SHA="${{ github.event.pull_request.head.sha }}"
56+ echo "Comparing PR: $BASE_SHA..$HEAD_SHA"
57+
58+ # Check if any monitored paths have changes
59+ for path in "${PATHS[@]}"; do
60+ if git diff --name-only "$BASE_SHA..$HEAD_SHA" | grep -E "^${path//\*/.*}" > /dev/null; then
61+ echo "Changes detected in: $path"
62+ EXAMPLES_CHANGED="true"
63+ break
64+ fi
65+ done
66+ elif [ "${{ github.event_name }}" = "push" ]; then
67+ # For pushes, compare against previous commit
68+ if [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
69+ BEFORE_SHA="${{ github.event.before }}"
70+ AFTER_SHA="${{ github.sha }}"
71+ echo "Comparing push: $BEFORE_SHA..$AFTER_SHA"
72+
73+ # Check if any monitored paths have changes
74+ for path in "${PATHS[@]}"; do
75+ if git diff --name-only "$BEFORE_SHA..$AFTER_SHA" | grep -E "^${path//\*/.*}" > /dev/null; then
76+ echo "Changes detected in: $path"
77+ EXAMPLES_CHANGED="true"
78+ break
79+ fi
80+ done
81+ else
82+ # First commit or force push, consider as changed
83+ echo "First commit or force push detected"
84+ EXAMPLES_CHANGED="true"
85+ fi
86+ else
87+ # For other events (like release), don't auto-detect changes
88+ echo "Event type: ${{ github.event_name }} - no automatic change detection"
89+ EXAMPLES_CHANGED="false"
90+ fi
91+
92+ echo "examples=$EXAMPLES_CHANGED" >> $GITHUB_OUTPUT
93+ echo "Examples changed: $EXAMPLES_CHANGED"
4694
4795 - name : Check for force build conditions
4896 id : check-force
0 commit comments