Skip to content

Commit 4e776c7

Browse files
hickeymaCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
1 parent 8663551 commit 4e776c7

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/issue-kind-label.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@ jobs:
1717
ISSUE_NUMBER: ${{ github.event.issue.number }}
1818
REPO: ${{ github.repository }}
1919
run: |
20+
# Extract /kind values from issue body. Absence of a directive is a no-op
21+
# to avoid wiping kind/* labels set by maintainers through the UI.
22+
kinds=$(printf '%s' "$ISSUE_BODY" | tr -d '\r' | sed -n 's|^/kind[[:space:]][[:space:]]*||p' | sed 's|[[:space:]]*$||' | sed '/^$/d' | sort -u)
23+
[ -z "$kinds" ] && exit 0
24+
2025
# Remove existing kind/* labels
2126
gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json labels \
2227
-q '.labels[].name | select(startswith("kind/"))' | \
2328
while IFS= read -r label; do
2429
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --remove-label "$label" || echo "::warning::Failed to remove label '$label'"
2530
done
2631
27-
# Extract /kind values from issue body and apply labels
28-
printf '%s' "$ISSUE_BODY" | tr -d '\r' | sed -n 's|^/kind[[:space:]][[:space:]]*||p' | sed 's|[[:space:]]*$||' | sort -u | \
32+
printf '%s\n' "$kinds" | \
2933
while IFS= read -r kind; do
30-
[ -z "$kind" ] && continue
3134
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --add-label "kind/$kind" || \
3235
echo "::warning::Label 'kind/$kind' not found in repository"
3336
done

0 commit comments

Comments
 (0)