From 843bd1cf3cbc7b74246e244b5a99dd845a1729cd Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Wed, 12 Mar 2025 04:02:14 +0100 Subject: [PATCH] Add check for PRs with merge-blocking labels --- .github/workflows/on-open-handler.yml | 2 +- .github/workflows/pr-auto-manager.yml | 44 ++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/on-open-handler.yml b/.github/workflows/on-open-handler.yml index 33327fbca..e4bab4a04 100644 --- a/.github/workflows/on-open-handler.yml +++ b/.github/workflows/on-open-handler.yml @@ -15,7 +15,7 @@ jobs: - name: Label if Author is a Repo Maintainer # GitHub Script # https://github.com/marketplace/actions/github-script - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | // Get basic info diff --git a/.github/workflows/pr-auto-manager.yml b/.github/workflows/pr-auto-manager.yml index 03ef5884e..1b733521f 100644 --- a/.github/workflows/pr-auto-manager.yml +++ b/.github/workflows/pr-auto-manager.yml @@ -73,9 +73,51 @@ jobs: with: repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + check-merge-blocking-labels: + name: Check Merge Blocking Labels + needs: [check-merge-conflicts, pr-size-labeler, label-release-prs, apply-file-based-labels] + runs-on: ubuntu-latest + + steps: + - name: Check Merge Blocking + # GitHub Script + # https://github.com/marketplace/actions/github-scriptLabels + id: label-check + uses: actions/github-script@v7 + with: + script: | + const prLabels = context.payload.pull_request.labels.map(label => label.name); + const blockingLabels = [ + "⛔ Don't Merge", + "🔨 Needs Work", + "🔬 Needs Testing", + "⛔ Waiting For External/Upstream", + "❗ Against Release Branch", + "💥💣 Breaking Changes" + ]; + const hasBlockingLabel = prLabels.some(label => blockingLabels.includes(label)); + + if (hasBlockingLabel) { + console.log("Blocking label detected. Setting warning status."); + await github.rest.checks.create({ + owner: context.repo.owner, + repo: context.repo.repo, + name: "PR Label Warning", + head_sha: context.payload.pull_request.head.sha, + status: "completed", + conclusion: "neutral", + output: { + title: "Potential Merge Issue", + summary: "This PR has a merge-blocking label. Proceed with caution." + } + }); + } else { + console.log("No merge-blocking labels found."); + } + pr-auto-comments: name: Post PR Comments Based on Labels - needs: [check-merge-conflicts, pr-size-labeler] + needs: [check-merge-conflicts, pr-size-labeler, label-release-prs, apply-file-based-labels] runs-on: ubuntu-latest steps: