From 4790ed772a8d73ee792320fac978fa874b85c71e Mon Sep 17 00:00:00 2001 From: Sawyer Date: Wed, 23 Oct 2024 16:38:50 -0400 Subject: [PATCH] improve pattern matching --- .github/workflows/dynamic-service-build.yml | 23 ++++++++++++++++++--- ml-api/Dockerfile | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dynamic-service-build.yml b/.github/workflows/dynamic-service-build.yml index db166e1..227e23a 100644 --- a/.github/workflows/dynamic-service-build.yml +++ b/.github/workflows/dynamic-service-build.yml @@ -46,12 +46,20 @@ jobs: # List of directories to exclude (space-separated) EXCLUDED_DIRS="deployment resources gef-portal-scraper" + echo "🔍 Changed files in this push/PR:" + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo " → $file" + done + # Find all Dockerfiles in service directories for dockerfile in $(find . -name "Dockerfile" -not -path "*/\.*"); do # Get service directory (parent of Dockerfile) service_dir=$(dirname "$dockerfile") service_name=$(basename "$service_dir") + echo "📦 Checking service: $service_name" + echo " • Directory: $service_dir" + # Skip if directory is in excluded list skip=false for excluded in $EXCLUDED_DIRS; do @@ -66,10 +74,17 @@ jobs: # Check for changes in service directory CHANGED=false for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - if [[ $file == $service_dir/* ]]; then + # Remove leading ./ from paths for consistent comparison + clean_file=$(echo "$file" | sed 's|^\./||') + clean_dir=$(echo "$service_dir" | sed 's|^\./||') + + echo " • Comparing changed file: $clean_file" + echo " • With service dir: $clean_dir" + + if [[ "$clean_file" == "$clean_dir"* ]]; then CHANGED=true echo "✨ Found changes in service: $service_name" - echo " Changed file: $file" + echo " Changed file: $clean_file" break fi done @@ -77,7 +92,9 @@ jobs: # If changes detected, add to build matrix if [ "$CHANGED" = true ]; then echo "🔨 Adding $service_name to build matrix" - MATRIX="${MATRIX}${SEPARATOR}{\"service\": \"${service_name}\", \"context\": \"${service_dir#./}\"}" + # Remove leading ./ from context path + context_path=$(echo "$service_dir" | sed 's|^\./||') + MATRIX="${MATRIX}${SEPARATOR}{\"service\": \"${service_name}\", \"context\": \"${context_path}\"}" SEPARATOR="," else echo "⏭️ No changes detected for $service_name - skipping" diff --git a/ml-api/Dockerfile b/ml-api/Dockerfile index a0ced98..c498279 100644 --- a/ml-api/Dockerfile +++ b/ml-api/Dockerfile @@ -59,4 +59,4 @@ EXPOSE 8000 CMD ["uvicorn", "ml_api.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"] -# test \ No newline at end of file +# test 1 \ No newline at end of file