diff --git a/src/github.sh b/src/github.sh index bf8273f..69b259d 100644 --- a/src/github.sh +++ b/src/github.sh @@ -59,9 +59,11 @@ github::has_label() { 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 + echo "1" return 0 fi done + echo "0" return 1 } diff --git a/src/labeler.sh b/src/labeler.sh index add76b0..b56c516 100644 --- a/src/labeler.sh +++ b/src/labeler.sh @@ -19,13 +19,14 @@ labeler::label() { log::message "Ignoring files (if present): $files_to_ignore" local -r label_to_add=$(labeler::label_for "$total_modifications" "$@") + local -r had_label=$(github::has_label "$pr_number" "$label_to_add") log::message "Labeling pull request with $label_to_add" 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" ] && ! github::has_label "$pr_number" "$label_to_add"; then + if [ -n "$message_if_xl" ] && [ "$had_label" -eq 0 ]; then github::comment "$message_if_xl" fi