Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Comment on PR only if the XL label is new #83

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ github::calculate_total_modifications() {
echo $((additions + deletions))
}

github::has_label() {
local -r pr_number="${1}"
local -r label_to_check="${2}"

local -r body=$(curl -sSL -H "Authorization: token $GITHUB_TOKEN" -H "$GITHUB_API_HEADER" "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/issues/$pr_number/labels")
for label in $(echo "$body" | jq -r '.[] | @base64'); do
if [ "$(echo ${label} | base64 -d | jq -r '.name')" = "$label_to_check" ]; then
return 0
fi
done
return 1
}

github::add_label_to_pr() {
local -r pr_number="${1}"
local -r label_to_add="${2}"
Expand Down
2 changes: 1 addition & 1 deletion src/labeler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ labeler::label() {
github::add_label_to_pr "$pr_number" "$label_to_add" "$xs_label" "$s_label" "$m_label" "$l_label" "$xl_label"

if [ "$label_to_add" == "$xl_label" ]; then
if [ -n "$message_if_xl" ]; then
if [ -n "$message_if_xl" ] && ! github::has_label "$pr_number" "$label_to_add"; then
github::comment "$message_if_xl"
fi

Expand Down
Loading