Skip to content

Commit

Permalink
{CI} Block PR merge on blocked labels (#7334)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzelin007 committed Apr 8, 2024
1 parent e00e734 commit f4a404b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/BlockPRMerge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Block PR merging on "do-not-merge" label
name: Block PR merging on blocled labels

on:
pull_request_target:
Expand All @@ -10,14 +10,16 @@ jobs:
block-merge:
runs-on: ubuntu-latest
steps:
- name: Check "do-not-merge" label
- name: Check blocked labels
uses: actions/github-script@v7
with:
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
if (labels.includes("do-not-merge")) {
console.log("It is not allowed to merge a PR with 'do-not-merge' label.");
const blockedLabels = ["do-not-merge", "needs-author-feedback"];
if (labels.some(label => blockedLabels.includes(label))) {
console.log(`It is not allowed to merge a PR with any blocked labels: ${blockedLabels}`);
process.exit(1); // Exit with a non-zero status code to block merge
} else {
console.log("It is allowed to merge a PR without 'do-not-merge' label.");
console.log("It is allowed to merge the PR.");
}

0 comments on commit f4a404b

Please sign in to comment.