File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,14 +84,18 @@ jobs:
8484 fi
8585
8686 # Block PRs with labels that indicate they are not ready to merge.
87- # Read labels line-by-line (jq outputs one per line) to handle
88- # multi-word label names; match with a single regex to avoid
89- # word-splitting "DO NOT MERGE" into individual grep patterns.
87+ # Match blocked labels exactly (case-insensitively) using the PR
88+ # payload we already have, instead of doing substring matches.
89+ BLOCKED_LABELS=$(jq -r '
90+ [.[].name | ascii_downcase] as $pr_labels
91+ | ["blocked", "do not merge"] as $blocking
92+ | $pr_labels - ($pr_labels - $blocking)
93+ | .[]
94+ ' <<<"$LABELS")
9095 while IFS= read -r label; do
91- if echo "$label" | grep -qiE "blocked|do not merge"; then
92- ERRORS="${ERRORS}- **Blocked label detected**: label \`$label\` prevents merging. Remove it when the PR is ready.\n"
93- fi
94- done < <(echo "$LABELS" | jq -r '.[].name')
96+ [ -n "$label" ] || continue
97+ ERRORS="${ERRORS}- **Blocked label detected**: label \`$label\` prevents merging. Remove it when the PR is ready.\n"
98+ done <<<"$BLOCKED_LABELS"
9599
96100 if [ -n "$ERRORS" ]; then
97101 echo "::error::This PR is missing required metadata. See the job summary for details."
You can’t perform that action at this time.
0 commit comments