Skip to content

Commit 13c6881

Browse files
committed
fix(ci): path-aware grep filters for -r output; harden .env API_BASE_URL on SSH
Made-with: Cursor
1 parent b337e47 commit 13c6881

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ jobs:
280280
# Guard 1: no stale network name (fieldtrack_network is not the canonical name)
281281
if grep -rE '\bfieldtrack_network\b' src/ scripts/ \
282282
--include='*.ts' --include='*.sh' \
283-
2>/dev/null | grep -Ev '^\s*#'; then
283+
2>/dev/null | grep -Ev '^[^:]+:\s*(#|//)'; then
284284
echo "::error::Forbidden network name 'fieldtrack_network' found — canonical name is 'api_network'"
285285
FAIL=1
286286
fi
@@ -898,7 +898,7 @@ jobs:
898898
# Scope: scripts/ and src/ only (not workflows where guard steps live).
899899
if grep -rE "\./infra/|\.\.\./infra/" scripts/ src/ \
900900
--binary-files=without-match --exclude-dir=node_modules 2>/dev/null \
901-
| grep -Ev '^\s*#'; then
901+
| grep -Ev '^[^:]+:\s*(#|//)'; then
902902
echo "::error::Local repo-relative infra coupling (./infra/ or ../infra/) detected in scripts/ or src/"
903903
exit 1
904904
fi
@@ -915,7 +915,8 @@ jobs:
915915
export DEPLOY_ROOT="${DEPLOY_ROOT:-$HOME/api}"
916916
[ -d "$DEPLOY_ROOT" ] || { echo "::error::DEPLOY_ROOT not found: $DEPLOY_ROOT"; exit 1; }
917917
cd "$DEPLOY_ROOT"
918-
API_BASE_URL=$(grep -E '^API_BASE_URL=' .env | head -1 | cut -d'=' -f2-)
918+
API_BASE_URL=$(grep -E '^API_BASE_URL=' .env 2>/dev/null | head -1 | cut -d'=' -f2- || true)
919+
[ -n "$API_BASE_URL" ] || { echo "::error::API_BASE_URL missing or empty in .env"; exit 1; }
919920
API_HOSTNAME=$(echo "$API_BASE_URL" | sed -E 's|^https?://||' | cut -d'/' -f1)
920921
for i in $(seq 1 30); do
921922
# Phase 1: in-network (source of truth)
@@ -951,7 +952,8 @@ jobs:
951952
export DEPLOY_ROOT="${DEPLOY_ROOT:-$HOME/api}"
952953
[ -d "$DEPLOY_ROOT" ] || { echo "::error::DEPLOY_ROOT not found: $DEPLOY_ROOT"; exit 1; }
953954
cd "$DEPLOY_ROOT"
954-
API_BASE_URL=$(grep -E '^API_BASE_URL=' .env | head -1 | cut -d'=' -f2-)
955+
API_BASE_URL=$(grep -E '^API_BASE_URL=' .env 2>/dev/null | head -1 | cut -d'=' -f2- || true)
956+
[ -n "$API_BASE_URL" ] || { echo "::error::API_BASE_URL missing or empty in .env"; exit 1; }
955957
API_HOSTNAME=$(echo "$API_BASE_URL" | sed -E 's|^https?://||' | cut -d'/' -f1)
956958
for i in $(seq 1 10); do
957959
# Phase 1: in-network (source of truth)

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
124124
if grep -rE '\bfieldtrack_network\b' src/ scripts/ \
125125
--include='*.ts' --include='*.sh' \
126-
2>/dev/null | grep -Ev '^\s*#'; then
126+
2>/dev/null | grep -Ev '^[^:]+:\s*(#|//)'; then
127127
echo "::error::Forbidden network name 'fieldtrack_network' — canonical name is 'api_network'"
128128
FAIL=1
129129
fi

0 commit comments

Comments
 (0)