From 09cbc9c7a8ea87d418981da3c86bf7c03a5f5996 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Wed, 30 Sep 2026 09:56:47 +0530 Subject: [PATCH] consolidate labeling on PRs. --- .github/workflows/pr_labeler.yml | 49 +++++++++----------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/.github/workflows/pr_labeler.yml b/.github/workflows/pr_labeler.yml index d657bed95116..9df5dc517ad4 100644 --- a/.github/workflows/pr_labeler.yml +++ b/.github/workflows/pr_labeler.yml @@ -11,38 +11,33 @@ jobs: label: permissions: contents: read + issues: read pull-requests: write runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + REPO: ${{ github.repository }} steps: + # label - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5 with: sync-labels: true - missing-tests: - permissions: - contents: read - issues: read - pull-requests: write - runs-on: ubuntu-latest - steps: + # missing-tests - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + id: checkout + if: ${{ !cancelled() }} with: ref: ${{ github.event.pull_request.base.sha }} - name: Check for missing tests id: check - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REPO: ${{ github.repository }} + if: ${{ !cancelled() && steps.checkout.outcome == 'success' }} run: | gh api --paginate "repos/${REPO}/pulls/${PR_NUMBER}/files" \ | python utils/check_test_missing.py - name: Add or remove missing-tests label if: always() - 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 'any(.[]; .name == "missing-tests")') if [ "${{ steps.check.outcome }}" = "failure" ]; then @@ -55,17 +50,9 @@ jobs: fi fi - fixes-issue: - permissions: - issues: read - pull-requests: write - runs-on: ubuntu-latest - steps: + # fixes-issue - name: Check for linked closing issues - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REPO: ${{ github.repository }} + if: ${{ !cancelled() }} run: | OWNER="${REPO%/*}" NAME="${REPO#*/}" @@ -93,17 +80,9 @@ jobs: fi fi - size-label: - permissions: - issues: read - pull-requests: write - runs-on: ubuntu-latest - steps: + # size-label - name: Label PR by diff size - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REPO: ${{ github.repository }} + if: ${{ !cancelled() }} run: | DIFF_SIZE=$(gh api "repos/${REPO}/pulls/${PR_NUMBER}" --jq '.additions + .deletions') if [ "$DIFF_SIZE" -lt 50 ]; then