Skip to content

Commit

Permalink
[Chore] add more labels based on PR title (StarRocks#325)
Browse files Browse the repository at this point in the history
Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao authored Nov 28, 2023
1 parent 6256bdb commit 5b05b87
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
36 changes: 36 additions & 0 deletions scripts/add-labels-to-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# input parameters: a list of PR numbers and a version tag
# e.g. v1.8.6 1 2 3 4 5
VERSION_TAG=$1

# create label by gh
gh label create $VERSION_TAG

shift
PR_NUMBERS=("$@")

# define an array of keywords
KEYWORDS=("feature" "enhancement" "bugfix" "chore" "documentation")

# iterate over the list of PR numbers
for PR_NUMBER in "${PR_NUMBERS[@]}"; do
# add a version label to each PR
gh pr edit $PR_NUMBER --add-label "$VERSION_TAG"

# get the PR title
PR_TITLE=$(gh pr view $PR_NUMBER --json title -q '.title')

# convert PR title to lowercase
PR_TITLE=$(echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]')

# check if the PR title contains any of the keywords
for KEYWORD in "${KEYWORDS[@]}"; do
if [[ $PR_TITLE == *"$KEYWORD"* ]]; then
# create the label if it doesn't exist
gh label create $KEYWORD 2>/dev/null
# add the label to the PR
gh pr edit $PR_NUMBER --add-label "$KEYWORD"
fi
done
done
17 changes: 0 additions & 17 deletions scripts/add-version-label-to-pr.sh

This file was deleted.

0 comments on commit 5b05b87

Please sign in to comment.