This is an automated email from the ASF dual-hosted git repository.
davidarthur pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 529095ba34c KAFKA-17542: Automatically label small PRs (#17260)
529095ba34c is described below
commit 529095ba34cc69ac8c74ae81429f3b166facd785
Author: TaiJuWu <[email protected]>
AuthorDate: Sat Oct 5 04:31:31 2024 +0800
KAFKA-17542: Automatically label small PRs (#17260)
Reviewers: Chia-Ping Tsai <[email protected]>, David Arthur
<[email protected]>
---
.../labeler.yml => scripts/label_small.sh} | 29 +++++++++++-----------
.github/workflows/labeler.yml | 9 ++++++-
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/.github/workflows/labeler.yml b/.github/scripts/label_small.sh
old mode 100644
new mode 100755
similarity index 63%
copy from .github/workflows/labeler.yml
copy to .github/scripts/label_small.sh
index 2fee16426c0..83466c0e705
--- a/.github/workflows/labeler.yml
+++ b/.github/scripts/label_small.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
@@ -13,19 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: "Pull Request Labeler"
-on:
- pull_request_target:
- types: [opened, reopened, synchronize]
-
+LABEL_NAME=small
+MAX_SIZE=100
-jobs:
- label_PRs:
- permissions:
- contents: read
- pull-requests: write
- runs-on: ubuntu-latest
- steps:
- - uses: actions/labeler@v5
- with:
- configuration-path: .github/configs/labeler.yml
+pr_diff=$(gh pr diff $PR_NUM -R $GITHUB_REPOSITORY)
+
+insertions=$(printf "$pr_diff" | grep '^+' | wc -l)
+deletions=$(printf "$pr_diff" | grep '^-' | wc -l)
+
+total_changes=$((insertions + deletions))
+if [ "$total_changes" -lt "$MAX_SIZE" ]; then
+ gh issue edit $PR_NUM --add-label $LABEL_NAME -R $GITHUB_REPOSITORY
+else
+ gh issue edit $PR_NUM --remove-label $LABEL_NAME -R $GITHUB_REPOSITORY
+fi
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
index 2fee16426c0..72a7e9313cb 100644
--- a/.github/workflows/labeler.yml
+++ b/.github/workflows/labeler.yml
@@ -17,7 +17,6 @@ name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened, reopened, synchronize]
-
jobs:
label_PRs:
@@ -26,6 +25,14 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
- uses: actions/labeler@v5
with:
configuration-path: .github/configs/labeler.yml
+ - name: check small label
+ env:
+ GH_TOKEN: ${{ github.token }}
+ PR_NUM: ${{github.event.number}}
+ run: |
+ ./.github/scripts/label_small.sh