diff --git a/.github/workflows/deploy-supabase.yml b/.github/workflows/deploy-supabase.yml index 1cb321a..0250d11 100644 --- a/.github/workflows/deploy-supabase.yml +++ b/.github/workflows/deploy-supabase.yml @@ -81,14 +81,18 @@ jobs: - name: Remove Deleted Functions run: | - # Get list of functions deployed on Supabase - deployed=$(supabase functions list --project-ref $SUPABASE_PROJECT_REF | tail -n +2 | awk '{print $1}') + # Get list of functions deployed on Supabase (skip header lines, extract slug column) + deployed=$(supabase functions list --project-ref $SUPABASE_PROJECT_REF | grep -E '^[a-z]' | awk '{print $1}') # Get list of functions in the repo (excluding _shared) local_functions=$(ls -d apps/supabase/functions/*/ 2>/dev/null | xargs -I {} basename {} | grep -v '^_shared$' || true) # Delete any deployed functions that no longer exist in the repo for func in $deployed; do + # Skip empty or invalid function names + [ -z "$func" ] && continue + [[ "$func" =~ ^[^a-z] ]] && continue + if ! echo "$local_functions" | grep -q "^${func}$"; then echo "Deleting removed function: $func" supabase functions delete "$func" --project-ref $SUPABASE_PROJECT_REF