Skip to content

Instantly share code, notes, and snippets.

@superbrothers
Created December 8, 2021 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superbrothers/511b21359faf35ae1321a5bc904d387c to your computer and use it in GitHub Desktop.
Save superbrothers/511b21359faf35ae1321a5bc904d387c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e -o pipefail; [[ -n "$DEBUG" ]] && set -x
curl_opts=(--silent -L)
if [[ -n "$PAT" ]]; then
curl_opts+=(-H "Authorization: token $PAT")
fi
cat | while read line; do
pr_nums=($(echo "$line" | grep -o -e "#[0-9]\+" | cut -d"#" -f 2 ||:))
if [[ "${#pr_nums[*]}" -eq 0 ]]; then
echo "$line"
continue
fi
sigs=()
for pr_num in "${pr_nums[@]}"; do
sigs+=( $(curl "${curl_opts[@]}" "https://api.github.com/repos/kubernetes/kubernetes/issues/${pr_num}/labels" | jq -r '.[] | select(.name | startswith("sig/")) | .name') )
done
if [[ "${#sigs[*]}" -eq 0 ]]; then
echo "$line"
continue
fi
echo "$line [$(IFS=","; echo "${sigs[*]}")]"
done
# vim: ai ts=2 sw=2 et sts=2 ft=sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment