Skip to content

Commit 91c9c66

Browse files
committed
fix(ci): broaden version filter and log url sample for jq debug
Two review follow-ups: 1. Tighten the versioned-docs filter from (1|2|3) to [0-9]+ so the regex stays correct when a future v5/v6 archive lands alongside today's v1-v3 legacy versions. Verified against fixtures including /docs/1.0.0/, /docs/4.0.0/, /docs/12.3.45/ — all dropped. 2. Print the first 5 parsed URLs before the jq step so a jq parse failure leaves something actionable in the Actions log. Updated the jq-failure error message to reference the "First 5 URLs" sample instead of the non-existent "URLs above" artifact. Signed-off-by: nehagup <15074229+nehagup@users.noreply.github.com>
1 parent 8033df7 commit 91c9c66

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

.github/workflows/main.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,19 @@ jobs:
8080
exit 0
8181
fi
8282
83-
# Filter to the current (unversioned) docs only:
83+
# Filter the sitemap URL list:
8484
# - drop auto-generated /tags/ pages (low-value for search indexing)
85-
# - drop legacy versioned docs (/docs/1.0.0/, 2.0.0/, 3.0.0/) to keep
86-
# submissions focused on the preferred current doc paths
85+
# - drop any versioned doc path like /docs/N.M.P/ so only the
86+
# current (unversioned) docs are submitted. Matching any numeric
87+
# major-minor-patch prefix keeps the rule correct when a future
88+
# v5/v6 archive lands alongside today's v1-v3 legacy versions.
8789
#
8890
# `|| true` makes the pipeline non-fatal under `set -euo pipefail`:
8991
# if every URL happens to be filtered out, grep returns 1, which
9092
# would otherwise abort the step before the empty-result check below.
9193
URLS=$(grep -oP '<loc>\K[^<]+' "$SITEMAP" \
9294
| grep -v '/tags/' \
93-
| grep -vE '/docs/(1|2|3)\.[0-9]+\.[0-9]+/' \
95+
| grep -vE '/docs/[0-9]+\.[0-9]+\.[0-9]+/' \
9496
| sort -u || true)
9597
9698
if [ -z "$URLS" ]; then
@@ -101,6 +103,12 @@ jobs:
101103
URL_COUNT=$(printf '%s\n' "$URLS" | wc -l | tr -d '[:space:]')
102104
echo "Submitting $URL_COUNT docs URLs to IndexNow"
103105
106+
# Log a small sample so jq/curl failures below have enough context
107+
# to debug from the log alone (otherwise the only artifact is a
108+
# count, and the operator can't tell which URL broke the payload).
109+
echo "First 5 URLs:"
110+
printf '%s\n' "$URLS" | head -5 | sed 's/^/ /'
111+
104112
# Explicit jq availability + payload-build checks: under
105113
# `set -euo pipefail` a missing/failing jq would abort the step
106114
# before the error/troubleshooting branches below could run,
@@ -111,7 +119,7 @@ jobs:
111119
fi
112120
113121
if ! JSON_URLS=$(printf '%s\n' "$URLS" | jq -R -s 'split("\n") | map(select(length > 0))'); then
114-
echo "::error::Failed to build the IndexNow JSON payload from the sitemap URL list. Inspect the URLs above for unexpected characters and rerun the workflow."
122+
echo "::error::Failed to build the IndexNow JSON payload from the sitemap URL list. See the 'First 5 URLs' sample logged above for unexpected characters, then rerun the workflow."
115123
exit 1
116124
fi
117125

0 commit comments

Comments
 (0)