Replace gh_token.txt with gh auth parsing in release notes.

pull/11989/head
Andriy Dzikh 2021-07-15 13:14:13 -07:00
parent b2eec008d4
commit b311c1b665
1 changed files with 11 additions and 6 deletions

View File

@ -18,10 +18,15 @@ set -eu -o pipefail
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if ! [[ -r "${DIR}/gh_token.txt" ]]; then # Parse the token from `gh auth`
echo "Missing '${DIR}/gh_token.txt'. Please create a GitHub token at https://github.com/settings/tokens and store in '${DIR}/gh_token.txt'." TMP_TOKEN=$(mktemp)
exit 1 gh auth status -t 2>&1 | sed -n -r 's/^.*Token: ([a-zA-Z0-9_]*)/\1/p' > "$TMP_TOKEN"
fi
# Ensure the token is deleted when the script exits, so the token is not leaked.
function cleanup_token() {
rm -f "$TMP_TOKEN"
}
trap cleanup_token EXIT
install_release_notes_helper() { install_release_notes_helper() {
release_notes_workdir="$(mktemp -d)" release_notes_workdir="$(mktemp -d)"
@ -58,12 +63,12 @@ echo "Thank you to our PR reviewers for this release!"
echo "" echo ""
AWK_FORMAT_ITEM='{printf "- %s (%d comments)\n", $2, $1}' AWK_FORMAT_ITEM='{printf "- %s (%d comments)\n", $2, $1}'
AWK_REVIEW_COMMENTS='NR>1{arr[$4] += $6 + $7}END{for (a in arr) printf "%d %s\n", arr[a], a}' AWK_REVIEW_COMMENTS='NR>1{arr[$4] += $6 + $7}END{for (a in arr) printf "%d %s\n", arr[a], a}'
"${DIR}/pullsheet" reviews --since "$recent_date" --repos kubernetes/minikube --token-path $DIR/gh_token.txt --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_REVIEW_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" "${DIR}/pullsheet" reviews --since "$recent_date" --repos kubernetes/minikube --token-path "$TMP_TOKEN" --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_REVIEW_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM"
echo "" echo ""
echo "Thank you to our triage members for this release!" echo "Thank you to our triage members for this release!"
echo "" echo ""
AWK_ISSUE_COMMENTS='NR>1{arr[$4] += $7}END{for (a in arr) printf "%d %s\n", arr[a], a}' AWK_ISSUE_COMMENTS='NR>1{arr[$4] += $7}END{for (a in arr) printf "%d %s\n", arr[a], a}'
"${DIR}/pullsheet" issue-comments --since "$recent_date" --repos kubernetes/minikube --token-path $DIR/gh_token.txt --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_ISSUE_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" | head -n 5 "${DIR}/pullsheet" issue-comments --since "$recent_date" --repos kubernetes/minikube --token-path "$TMP_TOKEN" --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_ISSUE_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" | head -n 5
if [[ "$recent" != *"beta"* ]]; then if [[ "$recent" != *"beta"* ]]; then
echo "" echo ""