From 901b39bee3736f192fc79881f5205dfbd529a981 Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Fri, 15 Dec 2023 14:21:21 +0800 Subject: [PATCH 1/7] update --- .github/policies/resourceManagement.yml | 2 ++ .github/workflows/BlockPRMerge.yml | 30 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 .github/workflows/BlockPRMerge.yml diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml index 2adf007721c..511c4065e3b 100644 --- a/.github/policies/resourceManagement.yml +++ b/.github/policies/resourceManagement.yml @@ -5729,6 +5729,8 @@ configuration: reviewer: zhoxing-ms - requestReview: reviewer: yanzhudd + - requestReview: + reviewer: qwuae1 - addLabel: label: Auto-Assign - assignTo: diff --git a/.github/workflows/BlockPRMerge.yml b/.github/workflows/BlockPRMerge.yml new file mode 100644 index 00000000000..b4e94988402 --- /dev/null +++ b/.github/workflows/BlockPRMerge.yml @@ -0,0 +1,30 @@ +name: Prevent Merge on "do-not-merge" Label + +on: + pull_request: + types: [labeled] + +jobs: + block-merge: + runs-on: ubuntu-latest + steps: + - name: Check "do-not-merge" label + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.CLI_BOT }} + script: | + const labels = context.payload.pull_request.labels.map(label => label.name); + if (labels.includes("do-not-merge")) { + console.log("PR contains 'do-not-merge' label. Blocking merge."); + const octokit = require('@octokit/rest')(); + octokit.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + event: 'REQUEST_CHANGES', + body: 'This PR contains "do-not-merge" label. Please remove the label before merging.' + }); + process.exit(1); // Exit with a non-zero status code to block merge + } else { + console.log("PR does not contain 'do-not-merge' label. Allow merge."); + } From 482153902075a6cf9dd358e920a9cafdcabac80c Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Fri, 15 Dec 2023 14:26:49 +0800 Subject: [PATCH 2/7] Update BlockPRMerge.yml --- .github/workflows/BlockPRMerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/BlockPRMerge.yml b/.github/workflows/BlockPRMerge.yml index b4e94988402..ef23c0a78e2 100644 --- a/.github/workflows/BlockPRMerge.yml +++ b/.github/workflows/BlockPRMerge.yml @@ -1,7 +1,7 @@ name: Prevent Merge on "do-not-merge" Label on: - pull_request: + pull_request_target: types: [labeled] jobs: From 1c2ec85766b1a44d2330c8215c98f526517dd697 Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Fri, 15 Dec 2023 15:21:55 +0800 Subject: [PATCH 3/7] Update BlockPRMerge.yml --- .github/workflows/BlockPRMerge.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/BlockPRMerge.yml b/.github/workflows/BlockPRMerge.yml index ef23c0a78e2..51d734dc869 100644 --- a/.github/workflows/BlockPRMerge.yml +++ b/.github/workflows/BlockPRMerge.yml @@ -2,13 +2,14 @@ name: Prevent Merge on "do-not-merge" Label on: pull_request_target: - types: [labeled] + types: [labeled, unlabeled] jobs: block-merge: runs-on: ubuntu-latest steps: - name: Check "do-not-merge" label + if: github.event_name == 'pull_request' && github.event.action == 'labeled' uses: actions/github-script@v5 with: github-token: ${{ secrets.CLI_BOT }} From afb0fb1da5e3621ead001671fcb9672a8b7d8019 Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Fri, 15 Dec 2023 15:41:28 +0800 Subject: [PATCH 4/7] Update BlockPRMerge.yml --- .github/workflows/BlockPRMerge.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/BlockPRMerge.yml b/.github/workflows/BlockPRMerge.yml index 51d734dc869..78ef046bb4d 100644 --- a/.github/workflows/BlockPRMerge.yml +++ b/.github/workflows/BlockPRMerge.yml @@ -9,22 +9,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Check "do-not-merge" label - if: github.event_name == 'pull_request' && github.event.action == 'labeled' uses: actions/github-script@v5 with: - github-token: ${{ secrets.CLI_BOT }} script: | const labels = context.payload.pull_request.labels.map(label => label.name); if (labels.includes("do-not-merge")) { console.log("PR contains 'do-not-merge' label. Blocking merge."); - const octokit = require('@octokit/rest')(); - octokit.pulls.createReview({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - event: 'REQUEST_CHANGES', - body: 'This PR contains "do-not-merge" label. Please remove the label before merging.' - }); process.exit(1); // Exit with a non-zero status code to block merge } else { console.log("PR does not contain 'do-not-merge' label. Allow merge."); From 4585d8affa6ce56254f3ceff231bc39f11dbd115 Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Fri, 15 Dec 2023 15:49:01 +0800 Subject: [PATCH 5/7] Update BlockPRMerge.yml --- .github/workflows/BlockPRMerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/BlockPRMerge.yml b/.github/workflows/BlockPRMerge.yml index 78ef046bb4d..8d3822e76fd 100644 --- a/.github/workflows/BlockPRMerge.yml +++ b/.github/workflows/BlockPRMerge.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check "do-not-merge" label - uses: actions/github-script@v5 + uses: actions/github-script@v7 with: script: | const labels = context.payload.pull_request.labels.map(label => label.name); From 4648df04027a4612a89e05319f947c795ef914fd Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Fri, 15 Dec 2023 15:53:11 +0800 Subject: [PATCH 6/7] Update AddIssueComment.yml --- .github/workflows/AddIssueComment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/AddIssueComment.yml b/.github/workflows/AddIssueComment.yml index 144bbb2c4de..f05623ca26d 100644 --- a/.github/workflows/AddIssueComment.yml +++ b/.github/workflows/AddIssueComment.yml @@ -8,7 +8,7 @@ jobs: name: Say thanks for the Issue steps: - name: comment on the issue - uses: hasura/comment-progress@v2.2.0 + uses: hasura/comment-progress@v2.3.0 with: github-token: ${{ secrets.CLI_BOT }} repository: 'Azure/azure-cli-extensions' From 74fa70b802189d03d087ef82f52c2bb643f8170a Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Thu, 21 Dec 2023 12:00:16 +0800 Subject: [PATCH 7/7] Update BlockPRMerge.yml --- .github/workflows/BlockPRMerge.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/BlockPRMerge.yml b/.github/workflows/BlockPRMerge.yml index 8d3822e76fd..c5f9ceb6b12 100644 --- a/.github/workflows/BlockPRMerge.yml +++ b/.github/workflows/BlockPRMerge.yml @@ -1,4 +1,4 @@ -name: Prevent Merge on "do-not-merge" Label +name: Block PR merging on "do-not-merge" label on: pull_request_target: @@ -14,8 +14,8 @@ jobs: script: | const labels = context.payload.pull_request.labels.map(label => label.name); if (labels.includes("do-not-merge")) { - console.log("PR contains 'do-not-merge' label. Blocking merge."); + console.log("It is not allowed to merge a PR with 'do-not-merge' label."); process.exit(1); // Exit with a non-zero status code to block merge } else { - console.log("PR does not contain 'do-not-merge' label. Allow merge."); + console.log("It is allowed to merge a PR without 'do-not-merge' label."); }