From 47879e412aecfb6c053dfde617454534ff3f4650 Mon Sep 17 00:00:00 2001 From: DN6 Date: Fri, 24 Apr 2026 10:52:41 +0530 Subject: [PATCH 1/2] update --- .github/workflows/pr_labeler.yml | 37 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr_labeler.yml b/.github/workflows/pr_labeler.yml index e80a68fb6d64..93ae2bb420fb 100644 --- a/.github/workflows/pr_labeler.yml +++ b/.github/workflows/pr_labeler.yml @@ -34,11 +34,17 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} + REPO: ${{ github.repository }} run: | + HAS_LABEL=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq '[.[].name] | contains(["missing-tests"])') if [ "${{ steps.check.outcome }}" = "failure" ]; then - gh pr edit "$PR_NUMBER" --add-label "missing-tests" + if [ "$HAS_LABEL" != "true" ]; then + gh pr edit "$PR_NUMBER" --add-label "missing-tests" + fi else - gh pr edit "$PR_NUMBER" --remove-label "missing-tests" 2>/dev/null || true + if [ "$HAS_LABEL" = "true" ]; then + gh pr edit "$PR_NUMBER" --remove-label "missing-tests" 2>/dev/null || true + fi fi fixes-issue: @@ -65,10 +71,15 @@ jobs: } }' \ --jq '.data.repository.pullRequest.closingIssuesReferences.totalCount') + HAS_LABEL=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq '[.[].name] | contains(["fixes-issue"])') if [ "${COUNT:-0}" -gt 0 ]; then - gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "fixes-issue" + if [ "$HAS_LABEL" != "true" ]; then + gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "fixes-issue" + fi else - gh pr edit "$PR_NUMBER" --repo "$REPO" --remove-label "fixes-issue" 2>/dev/null || true + if [ "$HAS_LABEL" = "true" ]; then + gh pr edit "$PR_NUMBER" --repo "$REPO" --remove-label "fixes-issue" 2>/dev/null || true + fi fi size-label: @@ -81,13 +92,19 @@ jobs: REPO: ${{ github.repository }} run: | DIFF_SIZE=$(gh api "repos/${REPO}/pulls/${PR_NUMBER}" --jq '.additions + .deletions') - for label in size/S size/M size/L; do - gh pr edit "$PR_NUMBER" --repo "$REPO" --remove-label "$label" 2>/dev/null || true - done if [ "$DIFF_SIZE" -lt 50 ]; then - gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "size/S" + DESIRED="size/S" elif [ "$DIFF_SIZE" -lt 200 ]; then - gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "size/M" + DESIRED="size/M" else - gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "size/L" + DESIRED="size/L" + fi + CURRENT_LABELS=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq '.[].name') + for label in size/S size/M size/L; do + if [ "$label" != "$DESIRED" ] && echo "$CURRENT_LABELS" | grep -qx "$label"; then + gh pr edit "$PR_NUMBER" --repo "$REPO" --remove-label "$label" 2>/dev/null || true + fi + done + if ! echo "$CURRENT_LABELS" | grep -qx "$DESIRED"; then + gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "$DESIRED" fi From 2db01a57268e29bc14b7f45d03a9f7caa6d70818 Mon Sep 17 00:00:00 2001 From: DN6 Date: Fri, 24 Apr 2026 16:21:06 +0530 Subject: [PATCH 2/2] update --- .github/workflows/pr_labeler.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr_labeler.yml b/.github/workflows/pr_labeler.yml index 93ae2bb420fb..3159979c1bfe 100644 --- a/.github/workflows/pr_labeler.yml +++ b/.github/workflows/pr_labeler.yml @@ -36,7 +36,7 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} REPO: ${{ github.repository }} run: | - HAS_LABEL=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq '[.[].name] | contains(["missing-tests"])') + HAS_LABEL=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq 'any(.[]; .name == "missing-tests")') if [ "${{ steps.check.outcome }}" = "failure" ]; then if [ "$HAS_LABEL" != "true" ]; then gh pr edit "$PR_NUMBER" --add-label "missing-tests" @@ -71,7 +71,7 @@ jobs: } }' \ --jq '.data.repository.pullRequest.closingIssuesReferences.totalCount') - HAS_LABEL=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq '[.[].name] | contains(["fixes-issue"])') + HAS_LABEL=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq 'any(.[]; .name == "fixes-issue")') if [ "${COUNT:-0}" -gt 0 ]; then if [ "$HAS_LABEL" != "true" ]; then gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "fixes-issue" @@ -93,18 +93,18 @@ jobs: run: | DIFF_SIZE=$(gh api "repos/${REPO}/pulls/${PR_NUMBER}" --jq '.additions + .deletions') if [ "$DIFF_SIZE" -lt 50 ]; then - DESIRED="size/S" + CANDIDATE_LABEL="size/S" elif [ "$DIFF_SIZE" -lt 200 ]; then - DESIRED="size/M" + CANDIDATE_LABEL="size/M" else - DESIRED="size/L" + CANDIDATE_LABEL="size/L" fi CURRENT_LABELS=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq '.[].name') for label in size/S size/M size/L; do - if [ "$label" != "$DESIRED" ] && echo "$CURRENT_LABELS" | grep -qx "$label"; then + if [ "$label" != "$CANDIDATE_LABEL" ] && echo "$CURRENT_LABELS" | grep -qx "$label"; then gh pr edit "$PR_NUMBER" --repo "$REPO" --remove-label "$label" 2>/dev/null || true fi done - if ! echo "$CURRENT_LABELS" | grep -qx "$DESIRED"; then - gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "$DESIRED" + if ! echo "$CURRENT_LABELS" | grep -qx "$CANDIDATE_LABEL"; then + gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "$CANDIDATE_LABEL" fi