Automate adding kind/* labels to cherry-pick PRs

This commit is contained in:
vladikkuzn
2026-02-16 16:41:12 +02:00
parent 31bf3ed48b
commit 70165283df

View File

@@ -134,6 +134,7 @@ trap return_to_kansas EXIT
SUBJECTS=()
RELEASE_NOTES=()
KIND_LABELS=()
function make-a-pr() {
local rel
rel="$(basename "${BRANCH}")"
@@ -142,6 +143,16 @@ function make-a-pr() {
local numandtitle
numandtitle=$(printf '%s\n' "${SUBJECTS[@]}")
local kind_commands=""
if [[ ${#KIND_LABELS[@]} -gt 0 ]]; then
while IFS= read -r label; do
if [[ -n "${label}" ]]; then
kind_commands+="/kind ${label#kind/}"$'\n'
fi
done < <(printf '%s\n' "${KIND_LABELS[@]}" | sort -u)
fi
prtext=$(cat <<EOF
Cherry pick of ${PULLSUBJ} on ${rel}.
@@ -149,6 +160,9 @@ ${numandtitle}
For details on the cherry pick process, see the [cherry pick requests](https://git.k8s.io/community/contributors/devel/sig-release/cherry-picks.md) page.
#### What type of PR is this?
${kind_commands}
\`\`\`release-note
$(printf '%s\n' "${RELEASE_NOTES[@]}")
\`\`\`
@@ -203,6 +217,13 @@ for pull in "${PULLS[@]}"; do
release_note=$(gh pr view "$pull" --json body --jq '.["body"]' | awk '/```release-note/{f=1;next} /```/{f=0} f')
RELEASE_NOTES+=("${release_note}")
# collect kind/* labels from the original PR
while IFS= read -r label; do
if [[ -n "${label}" ]]; then
KIND_LABELS+=("${label}")
fi
done < <(gh pr view "$pull" --json labels --jq '.labels[].name | select(startswith("kind/"))')
# remove the patch file from /tmp
rm -f "/tmp/${pull}.patch"
done