@@ -260,26 +260,64 @@ jobs:
260
260
echo "ENVIRONMENT: $ENVIRONMENT"
261
261
echo "DATABASE_NAME: $DATABASE_NAME"
262
262
263
+ # Configure git for better change detection
264
+ git config --global core.quotepath off
265
+ git fetch --prune --unshallow
266
+
263
267
deploy_component() {
264
268
local component_path=$1
265
269
local component_name=$2
266
270
local component_type=$3
267
271
268
- # Check if component files have changed since last deployment
269
- echo "Checking for changes in $component_path..."
272
+ echo "🔍 Checking for changes in $component_path..."
273
+
274
+ # Default to not deploying
275
+ should_deploy=false
270
276
271
- # Get the last commit hash where this component was changed
272
- local last_change=$(git log -n 1 --format=format:%H --full-diff -- "$component_path")
277
+ # For pull requests, always deploy components
278
+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
279
+ echo "Pull request detected - always deploying component"
280
+ should_deploy=true
281
+ # For workflow_dispatch, always deploy components
282
+ elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
283
+ echo "Manual workflow dispatch detected - always deploying component"
284
+ should_deploy=true
285
+ else
286
+ # Check for force_deploy file
287
+ if [[ -f "$component_path/.force_deploy" ]]; then
288
+ echo "🔥 Force deploy file found - forcing deployment"
289
+ should_deploy=true
290
+ else
291
+ # For push events, check if component changed in this commit
292
+ # Get changed files in the most recent commit
293
+ changed_files=$(git diff --name-only HEAD HEAD~1)
294
+ echo "Changed files in latest commit:"
295
+ echo "$changed_files"
296
+
297
+ # Check if any files in the component path changed
298
+ if echo "$changed_files" | grep -q "$component_path"; then
299
+ echo "✅ Changes detected in component"
300
+ should_deploy=true
301
+ else
302
+ echo "❌ No changes detected in component"
303
+ fi
304
+ fi
305
+ fi
273
306
274
- # If we're on main branch or there are changes in the component files, deploy
275
- if [[ -n "$last_change" && $(git rev-list HEAD^..HEAD | grep -c $last_change) -gt 0 ]]; then
276
- echo "⏳ Deploying $component_name (changes detected)..."
307
+ if $should_deploy; then
308
+ echo "⏳ Deploying $component_name..."
277
309
278
310
# Use our Python deployment script with additional logging
279
- PYTHONPATH=$PYTHONPATH:$(pwd) python -u scripts/snowflake_deployer.py deploy --profile $CONN_PROFILE --path "$component_path" --name "$component_name" --type "$component_type"
311
+ PYTHONPATH=$PYTHONPATH:$(pwd) python -u scripts/deployment_files/ snowflake_deployer.py deploy --profile $CONN_PROFILE --path "$component_path" --name "$component_name" --type "$component_type"
280
312
281
313
if [ $? -eq 0 ]; then
282
314
echo "✅ Successfully deployed $component_name"
315
+
316
+ # If force deploy file exists, remove it after successful deployment
317
+ if [[ -f "$component_path/.force_deploy" ]]; then
318
+ echo "Removing force deploy marker"
319
+ rm -f "$component_path/.force_deploy"
320
+ fi
283
321
else
284
322
echo "❌ Deploy failed for $component_name"
285
323
exit 1
0 commit comments