Skip to content

Commit 6e4241a

Browse files
committed
fix: properly detect worker file changes in CI
The previous condition used invalid GitHub context field. Now uses git diff to properly detect changes to workers/ or docker-compose.yml. Behavior: - Job always runs the check step - Detects if workers/ or docker-compose.yml modified - Only builds Docker images if workers actually changed - Shows clear skip message when no worker changes detected
1 parent d683448 commit 6e4241a

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,43 @@ jobs:
2121
build-workers:
2222
name: Build Worker Docker Images
2323
runs-on: ubuntu-latest
24-
# Only run if workers directory is modified
25-
if: |
26-
github.event_name == 'pull_request' &&
27-
contains(github.event.pull_request.changed_files, 'workers/')
2824
steps:
2925
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Fetch all history for proper diff
28+
29+
- name: Check if workers were modified
30+
id: check-workers
31+
run: |
32+
if [ "${{ github.event_name }}" == "pull_request" ]; then
33+
# For PRs, check changed files
34+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
35+
echo "Changed files:"
36+
echo "$CHANGED_FILES"
37+
38+
if echo "$CHANGED_FILES" | grep -q "^workers/\|^docker-compose.yml"; then
39+
echo "workers_modified=true" >> $GITHUB_OUTPUT
40+
echo "✅ Workers or docker-compose.yml modified - will build"
41+
else
42+
echo "workers_modified=false" >> $GITHUB_OUTPUT
43+
echo "⏭️ No worker changes detected - skipping build"
44+
fi
45+
else
46+
# For direct pushes, check last commit
47+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
48+
if echo "$CHANGED_FILES" | grep -q "^workers/\|^docker-compose.yml"; then
49+
echo "workers_modified=true" >> $GITHUB_OUTPUT
50+
else
51+
echo "workers_modified=false" >> $GITHUB_OUTPUT
52+
fi
53+
fi
3054
3155
- name: Set up Docker Buildx
56+
if: steps.check-workers.outputs.workers_modified == 'true'
3257
uses: docker/setup-buildx-action@v3
3358

3459
- name: Build worker images
60+
if: steps.check-workers.outputs.workers_modified == 'true'
3561
run: |
3662
echo "Building worker Docker images..."
3763
docker compose build worker-python worker-secrets worker-rust worker-android worker-ossfuzz --no-cache

0 commit comments

Comments
 (0)